def count_unique_strings(s): visited = set() from collections import deque q = deque() q.append(s) visited.add(s) n = len(s) while q: current = q.popleft() for i in range(n): for j in range(i+1, n+1): t = current[i:j] for k in range(j+1, n): for l in range(k+1, n+1): u = current[k:l] if len(t) == 0 or len(u) == 0: continue if (t.count('0') == u.count('0') and t.count('1') == u.count('1')): new_s = current[:i] + u + current[j:k] + t + current[l:] if new_s not in visited: visited.add(new_s) q.append(new_s) return len(visited) s = input().strip() print(count_unique_strings(s))