n = gets.to_s.to_i (2..36).each do |i| if n.to_s(i).bytes.uniq.size == 1 puts i exit end end (37..).each do |i| r = n % i k = n / i f = true while 0 < k s = k % i k /= i if s != r f = false break end end if f puts i exit end end