import Control.Monad

check :: [String] -> [String]
check = filter (\x -> '7' `elem` x && '5' `elem` x && '3' `elem` x)

solve :: Int -> [String]
solve 3 = check $ replicateM 3 "753"
solve n = check (replicateM n "753") ++ solve (n - 1)

main :: IO ()
main = do
  s <- getLine
  let list = map read . solve $ length s :: [Int]
  print . length $ filter (<= read s) list