#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <limits>
#include <tuple>
#include <cmath>

using ull = unsigned long long int;
using ll = long long int;

int main()
{
	std::string s;
	std::cin >> s;
	bool flag = true;
	for(ull i = 0; i<s.size(); i++)
	{
		if(i%2 == 0 and int(s[i]) < 96)
		{
			std::cout<<"No\n";
			flag = false;
			break;
		}
		else if(i%2 == 1 and int(s[i]) > 96)
		{
			std::cout<<"No\n";
			flag = false;
			break;
		}
	}
	if(flag) std::cout<<"Yes\n";
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,n;
  cin >> n;
  int ans=0;
  for(i=1;i<=n;i++){
    int a=i,res=0;
    while(a!=0){
      if(a%10==7){
        ans++,res=1;
        break;
      }
      a/=10;
    }
    if(res==1){
      continue;
    }
    a=i,res=0;
    while(a!=0){
      if(a%8==7){
        ans++,res=1;
        break;
      }
      a/=8;
    }
    if(res==1){
      continue;
    }
  }
  cout << n-ans << endl;
}