#!/usr/local/bin/ruby
# -*- mode: ruby -*-
# $Id: hash.ruby,v 1.2 2001/05/16 15:54:34 doug Exp $
# http://www.bagley.org/~doug/shootout/

n = Integer(ARGV.shift || 1)

X = {}
for i in 1 .. n
    X[sprintf("%x", i)] = 1
end

c = 0
(n).step(1,-1) do |i|
    if (X.has_key?(i.to_s)) then
    c += 1
    end
end

puts c