from collections import deque def count_distinct_strings(s): visited = set() q = deque() q.append(s) visited.add(s) n = len(s) while q: current = q.popleft() # Generate all possible swaps # Find all possible t and u pairs for t_start in range(n): for t_end in range(t_start, n): t = current[t_start:t_end+1] cnt0_t = t.count('0') cnt1_t = t.count('1') # Find u that is after t for u_start in range(t_end + 1, n): for u_end in range(u_start, n): u = current[u_start:u_end+1] cnt0_u = u.count('0') cnt1_u = u.count('1') if cnt0_t == cnt0_u and cnt1_t == cnt1_u: # Perform swap new_str = current[:t_start] + u + current[t_end+1:u_start] + t + current[u_end+1:] if new_str not in visited: visited.add(new_str) q.append(new_str) return len(visited) s = input().strip() print(count_distinct_strings(s))