import java.io.*; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null; while((str = in.readLine()) != null){ long num = Long.parseLong(str); long sum = 0; long temp = 1; while(temp <= num){ long i = temp +1; if(temp % 7 == 0){ sum ++; temp = i; continue; } while(temp > 0 ){ if(temp % 10 == 7){ sum ++; break; } temp /= 10; } temp = i; } System.out.println(sum); } } }