n = gets.chomp.to_i numbers = [] while (line = gets) max = line.chomp.split('').max if max >= '0' && max <= '9' base = max.to_i + 1 else base = max.ord - 'A'.ord + 10 + 1 end numbers << line.chomp.to_i(base) end puts numbers.min