import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.valueOf(scan.nextLine().trim());
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 7 == 0 || isContains(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
    public static boolean isContains(int num) {
        String str = String.valueOf(num);
        return str.contains("7");
    }
}