// 暴力解法:直接判断从1到n的所有数字。判断其与7是否有关
#include <iostream>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n+1; ++i){
        if(i % 7 == 0 || to_string(i).find('7') != string::npos){
            ans++;
        } 
    }

    cout << ans << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")