Under construction

Still being built. Things may change

Special Small Fountain

Time limit1sMemory limit512 MB

Summary
Given x0 and N, apply the rule that maps x to floor(x/2) XOR 6 when x is even or 2x XOR 6 when x is odd, N times, and print the result.
Level

Easy2 of 10

Topics
Implementation, Bit manipulation, Simulation
Solved
No attempts yet

Problem

This problem is the same as the "Special Big Fountain" problem, except for the limits on x_0x\_0 and NN.

NLCS has many fountains.

The water height in a fountain changes by a fixed rule. If the height of the fountain at integer time tt is the integer x_tx\_t, then x_t+1x\_{t+1} is ⌊x_t2⌋⊕6\lfloor \frac{x\_t}{2} \rfloor \oplus 6 when x_tx\_t is even, and (2⋅x_t)⊕6(2 \cdot x\_t) \oplus 6 when x_tx\_t is odd.

Given the height of the fountain at time 0, write a program that finds the height of the fountain at time NN.

Input

The first line contains x_0x\_0 and NN, the height of the fountain at time 0 and the time NN. Both x_0x\_0 and NN are integers.

Output

Print the height of the fountain at time NN on the first line.

Constraints

  • 0≤x_0,N≤1 0000 \le x\_0, N \le 1\,000

Hints

  • ⌊x⌋\lfloor x \rfloor is the largest integer less than or equal to xx.
  • ⊕\oplus is the bitwise XOR operator. See the Wikipedia article on bitwise operations for details. Most programming languages implement bitwise XOR as ^.

Examples2

  1. Example 1

    Input
    512 2
    
    Expected output
    133
    
  2. Example 2

    Input
    105 3
    
    Expected output
    48