#!/usr/bin/env python3 import sys def search(nums, maximum): # idx to consider i = 0 while len(nums) > 1: # count just that digit in the string (rest is garbage) counts = [0, 0] for n in nums: counts[int(n[i])] += 1 # filter the list down to most or least common is_zero = lambda x: x[i] == "0" is_one = lambda x: x[i] == "1" if (maximum and counts[0] > counts[1]) or (not maximum and counts[0] <= counts[1]): nums = list(filter(is_zero, nums)) else: nums = list(filter(is_one, nums)) i+=1 return nums[0] # We need multiple iterations on this one -- save to mem if __name__ == '__main__': nums = [] for l in sys.stdin: nums.append(l.strip()) oxygen = int(search(nums, maximum=True), 2) co2 = int(search(nums, maximum=False), 2) print(oxygen * co2)