from collections import deque def count_valid_swaps(s): visited = set() q = deque([s]) visited.add(s) n = len(s) while q: current = q.popleft() # Find all possible t and u pairs # t is [i, j], u is [k, l], j < k # Check all possible pairs for i in range(n): for j in range(i, n): t0 = current[i:j+1].count('0') t1 = (j - i + 1) - t0 # Now find u after j+1 for k in range(j+1, n): for l in range(k, n): u0 = current[k:l+1].count('0') u1 = (l - k + 1) - u0 if t0 == u0 and t1 == u1: # Swap t and u new_str = current[:i] + current[k:l+1] + current[j+1:k] + current[i:j+1] + current[l+1:] if new_str not in visited: visited.add(new_str) q.append(new_str) return len(visited) s = input().strip() print(count_valid_swaps(s))