#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_map>
#include<queue>
#include<deque>
#include<cmath>
#include<bitset>
#include<iomanip>
#include<stack>
#include<map>
#include<tuple>
#define ll long long

using namespace std;

bool ck(int n){
    int x = n;
    while (x > 0){
        if (x % 8 == 7) return false;
        x /= 8;
    }
    x = n;
    while (x > 0){
        if (x % 10 == 7) return false;
        x /= 10;
    }
    return true;
}

int main(){
	int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (ck(i)) ans++;
    }
    cout << ans;
}
#include<iostream>
using namespace std;

int main(){
  int n;
  cin >> n;
  n %= 100;
  n = 100-n;
  cout << n << endl;
}