public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
int n = sc.nextInt();
HashSet<Integer> set = new HashSet<>();
for (int i = 1; i <= n; i++) {
if (i % 7 == 0) {
set.add(i);
}
}
for (int i = 1; i <= n; i++) {
String s = String.valueOf(i);
for (int j = 0; j < s.length(); j++) {
if(s.charAt(j) == '7'){
set.add(i);
}
}
}
System.out.println(set.size());
}
}
}