n = gets.to_i str = "" for i in 1..n do str << i.to_s end # puts str puts str[n-1]