import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    xs = concatMap f [0, 2, 4, 6] :: [Int]
    f k = (+) <$> ((* (10 ^ k)) <$> [1..9]) <*> [0..(10 ^ k - 1)]
    m = length . takeWhile (<= n) $ xs
  print m

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
