import re import sys sys.setrecursionlimit(10**5) content = input() pattern = r'^([\(\)]+)$' result = re.match(pattern, content) if not result: sys.exit("format error.") s = content n = len(s) if n <= 0 or 10**5 < n: sys.exit("S") INF = 10**18 + 1 def sep(l, r): acc = 0 i = r - 1 while i >= l: if s[i] == ')': acc += 1 else: acc -= 1 if acc == 0: return i if acc < 0: return -1 i -= 1 return -1 def truncated_pow(a, n): val = 1 for _ in range(n): val *= a if val >= INF: return INF return val def solve(l, r, dep): if dep >= 6: return INF if l >= r: return 0 m = sep(l, r) if m == -1: return 1 val = solve(l, m, dep) + truncated_pow(2, solve(m + 1, r - 1, dep + 1)) if val >= INF: return INF return val res = solve(0, n, 0) if res >= INF: print("INFTY") else: print(res)