There is a strange counter. At the first second, it displays the number $3$. Each second, the number displayed by decrements by $\mbox{1}$ until it reaches $\mbox{1}$. In next second, the timer resets to $2\times\textbf{the initial number for the prior cycle}$ and continues counting down. The diagram below shows the counter values for each time $\boldsymbol{\boldsymbol{t}}$ in the first three cycles:

Find and print the value displayed by the counter at time $\boldsymbol{\boldsymbol{t}}$.  

Function Description  

Complete the strangeCounter function in the editor below.  

strangeCounter has the following parameter(s):  

int t: an integer   

Returns  

int: the value displayed at time $\boldsymbol{\boldsymbol{t}}$  

Input Format

A single integer, the value of $\boldsymbol{\boldsymbol{t}}$.

Constraints

$1\leq t\leq10^{12}$

Subtask

$1\leq t\leq10^5$ for $60\%$ of the maximum score.

Sample Input
4

Sample Output
6

Explanation

Time $t=4$ marks the beginning of the second cycle.  It is double the number displayed at the beginning of the first cycle:$2\times3=6$. This is shown in the diagram in the problem statement.

Difficulty: EASY

Solutions:
import sys
a1 = [1]
a2 = [3]
t = int(input())
br = int(1)
while a1[-1] <= t:
	a1.append(a1[br - 1] + a2[br - 1])
	a2.append(a2[br - 1] * 2)
	br += 1
res = a2[-2] - (t - a1[-2])
print(res)


(c, cmax) = (0, 3)
t = int(input().strip())
while c < t:
	c += cmax
	cmax *= 2
print(c - t + 1)