using System;
using System.Text;
using static System.Console;
namespace a755
{
    class a755
    {
        static void Main(string[] args)
        {
            long x = long.Parse(ReadLine());
            long op = 0;
            for (long i = 357; i <= x; i = i + 2)
            {
                string t = i.ToString();
                if (t.Contains("0") || t.Contains("1") || t.Contains("2") || t.Contains("4") || t.Contains("6") || t.Contains("8") || t.Contains("9"))
                {

                }
                else if (t.Contains("7") && t.Contains("5") && t.Contains("3"))
                {
                    op = ++op;
                }
            }
            WriteLine(op);
        }
    }
}