#include <bits/stdc++.h>
using namespace std;
bool is_7_beishu(int num){
if(num % 7 == 0){
return true;
}
return false;
}
bool bao_han_7(int num){
string tmp = to_string(num);
for(char c : tmp){
if(c == '7'){
return true;
}
}
return false;
}
void process(int n, int& res){
for(int i = 1; i <= n; i++){
if(is_7_beishu(i) || bao_han_7(i)){
res++;
}
}
}
int main(){
int n = 0;
cin >> n;
int res = 0;
process(n, res);
cout << res << endl;
return 0;
}