import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
while(scanner.hasNext()) {
Integer im = Integer.parseInt(scanner.nextLine());
int m=0;

        for(int i=1;i<=im;i++) {
            if(i%7==0) {
                m++;

            }
            else {
                if(Pattern.matches(".*7.*", String.valueOf(i))) {
                    m++;
                }
            }
        }
        System.out.println(m);
    }
}

}