from collections import deque def count_possible_strings(s): visited = set() queue = deque([s]) visited.add(s) while queue: current = queue.popleft() n = len(current) # Generate all possible t and u pairs where t is before u for lt in range(n): for rt in range(lt, n): t = current[lt:rt+1] t0 = t.count('0') t1 = len(t) - t0 # Look for u after t for lu in range(rt + 1, n): for ru in range(lu, n): u = current[lu:ru+1] u0 = u.count('0') u1 = len(u) - u0 if t0 == u0 and t1 == u1: # Swap t and u new_str = current[:lt] + u + current[rt+1:lu] + t + current[ru+1:] if new_str not in visited: visited.add(new_str) queue.append(new_str) # Generate all possible t and u pairs where u is before t for lu in range(n): for ru in range(lu, n): u = current[lu:ru+1] u0 = u.count('0') u1 = len(u) - u0 # Look for t after u for lt in range(ru + 1, n): for rt in range(lt, n): t = current[lt:rt+1] t0 = t.count('0') t1 = len(t) - t0 if t0 == u0 and t1 == u1: # Swap u and t new_str = current[:lu] + t + current[ru+1:lt] + u + current[rt+1:] if new_str not in visited: visited.add(new_str) queue.append(new_str) return len(visited) s = input().strip() print(count_possible_strings(s))