local n = io.read("*n") local nl = 1LL * n local c = 0 for i = 1, 99999 do local str = tostring(i):rep(3) local z = 1LL * tonumber(str) if z <= n then c = c + 1 end end print(c)