d = gets.chomp.to_i string = "" d.times {|i| string += (i + 1).to_s } puts string[d - 1]