def fib(n): if n <= 2: return ((n + 1) >> 1, (n + 2) >> 1) a, b = fib((n >> 1) - 1) # a * a is slightly faster than a * b in PyPy # (rpython/rlib/rbigint.py) a2, b2 = a * a, b * b e = (-2 if (n >> 1) & 1 else 2) c = b2 + a2 d = (b2 << 2) - a2 + e if n & 1: return (d, (d << 1) - c) else: return (d - c, d) def fast_divmod(a, b): """ Burnikel & Ziegler """ DIVMOD_THRESHOLD = 6000 def _pack(pack, shamt): size = len(pack) while size > 1: npack = [] for i in range(0, size - 1, 2): npack.append(pack[i] | (pack[i+1] << shamt)) if size & 1: npack.append(pack[-1]) pack = npack size = (size + 1) >> 1 shamt <<= 1 return pack[0] def _unpack(M, size, shamt): needed_sizes = [] s = size while s > 1: needed_sizes.append(s) s = (s + 1) >> 1 ret = [M] for needed_size in needed_sizes[::-1]: mask = (1 << shamt) - 1 nret = [] for c in ret: nret.append(c & mask) nret.append(c >> shamt) ret = nret[:needed_size] shamt >>= 1 return ret def _div32(a21, a0, b, b1, b0, n): if (a21 >> n) >= b1: q, r = (1 << n) - 1, a21 - (b1 << n) + b1 else: q, r = _div21(a21, b1, n) r = ((r << n) | a0) - q * b0 while r < 0: q -= 1 r += b return q, r def _div21(a, b, n): if a < b: return (0, a) if n <= DIVMOD_THRESHOLD: return divmod(a, b) odd = n & 1 if odd: a, b, n = a << 1, b << 1, n + 1 nh = n >> 1 mask = (1 << nh) - 1 b1, b0 = b >> nh, b & mask q1, r = _div32(a >> n, (a >> nh) & mask, b, b1, b0, nh) q0, r = _div32(r, a & mask, b, b1, b0, nh) if odd: r >>= 1 return (q1 << nh) | q0, r if a < b: return (0, a) n = b.bit_length() if n <= DIVMOD_THRESHOLD: return divmod(a, b) nqs = a.bit_length() // n a_blocks = _unpack(a, nqs + 1, (n << (nqs.bit_length() - 1))) qs = [] r = a_blocks[-1] for i in range(nqs - 1, -1, -1): q, r = _div21((r << n) | a_blocks[i], b, n) qs.append(q) q = _pack(qs[::-1], n) return q, r def print_big_integer(N, out=None, newline=True, beg=0, tens=None): def rec(N, e, zerofill=False): if e <= 10: if not zerofill: out.write("%s" % str(N)[beg:]) else: out.write("%0*d" % (1 << e, N)) else: ten = tens[e-1] q, r = fast_divmod(N, ten) if zerofill or q: rec(q, e - 1, zerofill) rec(r, e - 1, True) else: rec(r, e - 1, zerofill) if out is None: import sys out = sys.stdout if N < 0: N = -N out.write("-") if tens is None: tens = [] ten = 10 while ten <= N: tens.append(ten) if ten.bit_length() * 2 - 1 > N.bit_length(): break ten *= ten e = 0 while e < len(tens) and N >= tens[e]: e += 1 rec(N, e) if newline: out.write("\n") return def prob303(): import sys n = int(sys.stdin.readline()) if n == 2: print("3") print("INF") else: if n & 1: ans = fib(n)[0] else: a, b = fib(n // 2 - 1) ans = (a * b) << 1 print(n) # print(ans) print_big_integer(ans) prob303()