n=gets.to_i small=nil n.times{ e=gets.chomp k=e.bytes.max t=e.to_i(k>=65 ? (k-54) : (k-47)) small=t if !small||t