package main import ( "bufio" "os" "strconv" "fmt" ) var _s = bufio.NewScanner(os.Stdin) func next() string { _s.Scan() return _s.Text() } func nextLine() string { _s.Scan() return _s.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i } func nextLong() int64 { i, e := strconv.ParseInt(next(), 10, 64) if e != nil { panic(e) } return i } //aのb乗をします func pow(a int, b int) int { total := 1 tmp := a for b > 0 { if b%2 == 1 { total*=tmp } b/=2 tmp*=tmp } return total } /** 与えられた文字を32進数とみなして値を返します。 */ func getNumber(c uint8) int { if '0' <= c && c <= '9' { return int(c - '0') }else if 'A' <= c && c <= 'Z' { return int(c - 'A') + 10 }else if 'a' <= c && c <= 'z' { return int(c - 'a') + 10 } panic("") } func getNumberBase(s string, base int) (int) { k := 1 total := 0 for i := len(s) - 1; i >= 0; i-- { number := getNumber(s[i]) if number >= base { return -1 } total+=number*k k*=base } return total } func getMinNumberBase(s string) int { mn := getNumberBase("ZZZZZZZZZZZZ", 36) for i := 2; i <= 36; i++ { v := getNumberBase(s, i) if v == -1 { continue } if mn > v { mn = v } } return mn } func main() { N,_ := strconv.Atoi(nextLine()) s := nextLine() mn := getMinNumberBase(s) for i := 1; i < N; i++ { s := nextLine() v := getMinNumberBase(s) if mn > v { mn = v } } fmt.Println(mn) }