using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner input;
    static void Main()
    {
        input = new Scanner();
        string s = input.String();
        int count = 0;
        for(int a = 1; a <= int.Parse(s); a++)
        {
            if (a.ToString().Contains("7") && a.ToString().Contains("5") && a.ToString().Contains("3")&&countChar(a.ToString(),"7")+ countChar(a.ToString(), "5")+ countChar(a.ToString(), "3")==s.Length) count++;
        }
        WriteLine(count);

    }
    static int countChar(string s,string key)
    {
        return s.Length - s.Replace(key, "").Length;
    }
}

class Scanner
{

    public Scanner()
    {
    }

    public void skip()
    {
        ReadLine();
        return;
    }
    public string String()
    {
        return ReadLine();
    }
    public string[] splitString()
    {
        return ReadLine().Split();
    }
    public string[] linesString(int len)
    {
        var arr = new string[len];
        for(int a = 0; a < len; a++)
        {
            arr[a] = ReadLine();
        }
        return arr;
    }
    public string[][] jaggedArrayString(int len)
    {
        var arr = new string[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split();
        }
        return arr;
    }
    public int Int()
    {
        return int.Parse(ReadLine());
    }
    public int[] splitInt()
    {
        return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    }
    public int[] linesInt(int len)
    {
        var arr = new int[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = int.Parse(ReadLine());
        }
        return arr;
    }
    public int[][] jaggedArrayInt(int len)
    {
        var arr = new int[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        }
        return arr;
    }
    public long Long()
    {
        return long.Parse(ReadLine());
    }
    public long[] splitLong()
    {
        return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
    }
    public long[] linesLong(int len)
    {
        var arr = new long[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = long.Parse(ReadLine());
        }
        return arr;
    }
    public long[][] jaggedArrayLong(int len)
    {
        var arr = new long[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => long.Parse(i)).ToArray();
        }
        return arr;
    }
    public double Double()
    {
        return double.Parse(ReadLine());
    }
    public double[] splitDouble()
    {
        return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
    }
    public double[] linesDouble(int len)
    {
        var arr = new double[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = double.Parse(ReadLine());
        }
        return arr;
    }
    public double[][] jaggedArrayDouble(int len)
    {
        var arr = new double[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => double.Parse(i)).ToArray();
        }
        return arr;
    }
}