#include #include #include #include #include #include int sub1(char in) { if( '0' <= in && in <= '9' ) { return (in - '0'); } if( 'A' <= in && in <= 'Z' ) { return (in - 'A' + 10); } return 0; } int main() { /* default begin */ long i, j, k; long n, m; long temp; long t; std::vector v; bool b; /* default end */ std::string str; long N; std::cin >> N; for(i = 0; i < N; i++) { std::cin >> str; long max = 0; for(j = 0; j < str.length(); j++) { if( max < sub1(str[j]) ) { max = sub1(str[j]); } } temp = 0; for(j = 0; j < str.length(); j++) { temp *= (max+1); temp += sub1(str[j]); } v.push_back(temp); } std::sort(v.begin(), v.end()); std::cout << v[0] << std::endl; return 0; }