<?php

$lines = array_map('str_split', explode("\n", file_get_contents('input.txt')));
$lines = array_map('array_reverse', array_map(null, ...$lines)); // matrix rotation

$gamma = '';
$epsilon = '';

foreach ($lines as $line) {
    $counts = array_count_values($line);
    $max = array_search(max($counts), $counts);
    $gamma .= $max;
    $epsilon .= $max === 1 ? 0 : 1;
}

echo bindec($gamma) * bindec($epsilon);