module main; import std; import std.ascii : isDigit; void main() { // 入力 auto N = readln.chomp.to!int; auto V = new string[](N); foreach (ref v; V) v = readln.chomp.stripLeft("0"); // 左端の0を取り除く // 答えの計算 ulong ans = ulong.max; foreach (i; 0 .. N) { if (V[i] == "") { ans = 0; break; } auto c = V[i].maxElement; int radix; if (isDigit(c)) radix = c - '0' + 1; else radix = c - 'A' + 11; ulong tmp = V[i].to!ulong(radix); ans = min(ans, tmp); } // 答えの出力 writeln(ans); }