#include using namespace std; template inline T toInteger(const string&); template<> inline int toInteger(const string& s) { return stoi(s); } template<> inline long toInteger(const string& s) { return stol(s); } template<> inline long long toInteger(const string& s) { return stoll(s); } template inline T toInteger(const string& s, int n) { T res = 0; for (char c : s) { if (isdigit(c)) res = res * n + c - '0'; else if (isalpha(c)) res = res * n + tolower(c) - 'a' + 10; } return s[0] == '-' ? -res : res; } int main() { int n; cin >> n; long long res = numeric_limits::max(); for (int i = 0; i < n; ++i) { string v; cin >> v; int mx = 0; for (char c : v) { if (isdigit(c)) mx = max(mx, c - '0' + 1); else if (isalpha(c)) mx = max(mx, c - 'A' + 11); } res = min(res, toInteger(v, mx)); } cout << res << endl; }