import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=null;
while((s=br.readLine())!=null){
int n=Integer.valueOf(s);
int count=0;
for(int i=7;i<=n;i++){
count=count+youqi(i);
}
System.out.println(count);
}
}
public static int youqi(int n){
if(n%7==0) return 1;
while(n>=7){
if(n%10==7) return 1;
n=n/10;
}
return 0;
}
}