#include <bits/stdc++.h>
using namespace std;

typedef long L;
typedef long long LL;

const int MAXN = 1e5+10;

bool D[MAXN]={true}, O[MAXN]={true};

int main() {
    int N;
    cin >> N;
    int s = 0;
    for(int i=1; i<=N; i++) {
        int d =  i/10;
        if(i%10==7) {
            D[i] = false;
        } else {
            if(d) {
                if(D[d]==false) {
                    D[i] = false;
                } else {
                    D[i] = true;
                }
            } else {
                D[i] = true;
            }
        }
        int o =  i/8;
        if(i%8==7) {
            O[i] = false;
        } else {
            if(o) {
                if(O[o]==false) {
                    O[i] = false;
                } else {
                    O[i] = true;
                }
            } else {
                O[i] = true;
            }
        }
        if(D[i]==false||O[i]==false) {
            s++;
        }
    }
    cout << N-s << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define int long long 

ostream& operator << (ostream& stream, const vector<int>& v) {
  for(int x : v) {
    stream << x << " ";
  }
  return stream;
}

//ostream& operator << (ostream& stream, const int *a) {
  //for(int i = 0; i < n; i++) {
    //stream << *(a + i) <<  " ";
  //}
  //return stream;
//}

int ncr(int n, int r) {
  if(r==0 || r==n) {
    return 1;
  }
  int ans = ncr(n-1, r-1);
  ans *= n;
  return ans/r;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int l;
  cin >> l;
  //(l-1)C11
  cout << ncr(l-1, 11LL) << '\n';
  return 0;
}
  
  
