stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

 

int main(){

	int a, b;

	cin >> a >> b;

	if(a == 1 && a != b) cout << "Alice" << endl;

	else if(b == 1 && a != b) cout << "Bob" << endl;

	else if(a > b) cout << "Alice" << endl;

	else if(a < b) cout << "Bob" << endl;

	else if(a == b) cout << "Draw" << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>





using namespace std;







int main(){



int a,b;





scanf("%d",&a);

scanf("%d",&b);



if(a==1){



    a=14;

}

if(b==1){



    b=14;

}







 if(a>b ){



    printf("Alice\n");





}

else if(b>a){



    printf("Bob\n");

}





else{



    printf("Draw\n");

}













}


// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

      int a,b;

      cin>>a>>b;

    if(a==b)printf("Draw\n");

    else if((a==1&&b!=1)|| a>b&&b!=1)printf("Alice\n");

    else if((b==1&&a!=1)|| b>a&&a!=1)printf("Bob\n");

}


// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



int main()

{

   int a,b;

   cin>>a>>b;

   

   if(a==b){

   	cout<<"Draw";

   	return 0;

   }

   

   if(a==1 && b!=1){

   	cout<<"Alice";

   	return 0;

   }

   

   if(b==1 && a!=1){

   	cout<<"Bob";

   	return 0;

   }

   

   if(a>b){

   	cout<<"Alice";

   	return 0;

   }

   else

   cout<<"Bob";

   return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int A,B;

int main(){

	cin>>A>>B;

	if(A==B) {

		cout<<"Draw"<<endl;

	} else if(A==1) {

		cout<<"Alice"<<endl;

	} else if(B==1) {

		cout<<"Bob"<<endl;

	} else if(A>B) {

		cout<<"Alice"<<endl;

	} else if(A<B) {

		cout<<"Bob"<<endl;

	}

}


// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main() {

    int a, b, x = 1;

    cin>>a>>b;

    if(a==b){

        cout<<"Draw";

    }

    if((a>b || a==x) && (b!=x)  )

        cout<<"Alice";

    if((b>a || b==x) && (a!=x))

        cout<<"Bob";

}




// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main() {

    int a,b;

    cin>>a>>b;

    if(a==b) {

        cout<<"Draw";

    }

    else if(a==1){

        cout<<"Alice";

    }

    else if(b==1){

        cout<<"Bob";

    }

    else if(a>b){

        cout<<"Alice";

    }

    else{

        cout<<"Bob";

    }

    system("pause");

}


// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



int main(){

	int A ,B;

	cin >>A >> B;

	if (A>B && B!=1 || A<B && A==1)

		cout << "Alice";

	else if (B>A && A!=1 ||B<A && B==1)

		cout << "Bob";

	else 

		cout << "Draw";

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int Bob, Alice, Draw, x ,y;



int main () {

    cin >> x >> y;

    if (x==y){

        cout << "Draw" << endl;

    }else if (y==1){

        cout << "Bob" << endl;

    }else if ((x>y)||(x==1)){

        cout << "Alice" << endl;

    }else if (x==1){

        cout << "Alice" << endl;

    }else{

        cout << "Bob" << endl;

}

}


// Optimized solution to the same problem (faster):
#include <cstdio>

using namespace std;

int main ()

{

    int a,b;

    scanf("%d %d",&a,&b);

    if(a==b)

        printf("Draw\n");



    else if(a<b)

    {

        if(a==1)

        {

            printf("Alice\n");

        }

        else

            printf("Bob\n");

    }

    else if(a>b)

    {

        if(b==1)

            printf("Bob\n");

        else

            printf("Alice\n");

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

vector<int> vi[maxii];

vector<int>:: iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

bool check[maxii];

int cnt=0,n;

void dfs(int node)

{

    check[node]=true;

    if(vi[node].size()==n-1)cnt++;

    for(int child=0;child<vi[node].size();child++)

    {

        if(check[vi[node][child]]==false)

        {

            dfs(vi[node][child]);

        }

    }

}



int main()

{

    int a,b;

    cin>>a>>b;

    if(a==1)a=14;

    if(b==1)b=14;

    if(a==b)cout<<"Draw";

    else if(a>b)cout<<"Alice";

    else cout<<"Bob";



}










// Optimized solution to the same problem (faster):
#include <iostream>



using namespace std;



int main()

{

    int A,B;

    cin>>A>>B;

    if(A==1)

    {

        if(B==1)

            cout<<"Draw";

        else cout<<"Alice";

    }

    else if(B==1)

    {

        if(A==1)

            cout<<"Draw";

        else cout<<"Bob";

    }

    else {

        if(A>B)

            cout<<"Alice";

        else if(B>A)

            cout<<"Bob";

        else cout<<"Draw";

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<map>

#include<cmath>

//#include<windows.h>

#include<algorithm>

#include<set>

const double eps = 1e-1;

using namespace std;

typedef long long ll;



int n,e[] = {3,5,7},len,ans,dig[12];

bool t[10];

char a[13];



void dfs(int d){

    if(d>len+1)return;

    if(d>3){

        int sum=0;

        int cnt=0;

        set<int>s;

        for(int i=1;i<d;i++){

            sum = sum*10+dig[i];

            s.insert(dig[i]);

        }

        if(s.size()==3&&sum<=n){

            ans++;

//            cout<<sum<<endl;

        }

        s.clear();

    }



    for(int i=0;i<3;i++){

            dig[d] = e[i];

            dfs(d+1);

    }

}

int main(){

    scanf("%d",&n);

    sprintf(a,"%d",n);



    len = strlen(a);

//    cout<<len<<endl;

    dfs(1);

    printf("%d\n",ans);

    return 0;

}

//Hello World Here I Come

//          0                 10

//        0 1 1                8

//      0 1 1 2 3              6

//    0 1 1 2 3 5 8            4

//  0 1 1 2 3 5 8 13 21        2

//0 1 1 2 3 5 8 13 21 34 55    0


// Optimized solution to the same problem (faster):
#include<stdio.h>



long long N;

int num;



void DFS(long long nown,unsigned int flag){

	if(nown<=N){

		if(flag==7) num++;

		DFS(nown*10+3,flag|1);

		DFS(nown*10+5,flag|2);

		DFS(nown*10+7,flag|4);

	}

}



int main(){

	while(scanf("%d",&N)==1){

		num=0;

		DFS(0,0);

		printf("%d\n",num);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int num,res;



//ac是这些数字排列成的数字

//cnt表示已经有多少位置了



bool ok(long long n)

{

    int ret = 0;

    int cur;

    while(n)

    {

        cur = n%10;

        n /= 10;

        if(cur == 3) ret |= 1;

        else if(cur == 5) ret |= 2;

        else if(cur == 7) ret |= 4;

    }

    return ret == 7;

}



void dfs(long long ac)

{

    if(ac > num) return;

    else

    {

        if(ok(ac))

            ++res;

    }

    dfs(ac*10+3);

    dfs(ac*10+5);

    dfs(ac*10+7);

}



int main()

{

    scanf("%d",&num);

    res = 0;

    dfs(0);

    printf("%d\n",res);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



long long N;

int num;



void DFS(long long nown,unsigned int flag){

	if(nown<=N){

		if(flag==7) num++;

		DFS(nown*10+3,flag|1);

		DFS(nown*10+5,flag|2);

		DFS(nown*10+7,flag|4);

	}

}



int main(){

	while(scanf("%d",&N)==1){

		num=0;

		DFS(0,0);

		printf("%d\n",num);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string.h>

using namespace std;

int N,count=0;



void getNum(long long num,int flag){

	int baiwei = flag/100;

	int shiwei = flag/10%10;

	int gewei = flag%10;

	if(num<=N){

		if(baiwei&&shiwei&&gewei){

			count++;

		}

		int temp1=flag,temp2=flag,temp3=flag;

		if(baiwei==0){

			temp1+=100;

		}

		getNum(num*10+3,temp1);

		if(shiwei==0){

			temp2+=10;

		}

		getNum(num*10+5,temp2);

		if(gewei==0){

			temp3+=1;

		}

		getNum(num*10+7,temp3);

	}

}



int main(){

	scanf("%d",&N);

	getNum(0,0);

	printf("%d\n",count);

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int count1=0;

int num;

void xiandan(long long n,unsigned char flag)

{

    if(n<=num)

    {

        if(flag==07)



        count1++;



            xiandan(n*10+3,flag|01);

            xiandan(n*10+5,flag|02);

            xiandan(n*10+7,flag|04);









    }



}

int main()

{

    scanf("%d",&num);

    xiandan(0,0);

    printf("%d",count1);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <queue>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <set>

using namespace std;

using std::sort;

using std::binary_search;



#define MAX 100004

int cnt=0;

int t;

void dfs(long long  x,int flag){

    if(x>t){

        return;

    }

    if(flag==7){

        cnt++;

    }

    dfs(x*10+3,flag|1);

     dfs(x*10+5,flag|2);

     dfs(x*10+7,flag|4);



}

int main(){



//    printf("1\n");

    scanf("%d",&t);

    dfs(0,0);

    printf("%d",cnt);

}




// Optimized solution to the same problem (faster):
#include <cstdio>

int N,count=0;

void dfs(long long,int);

int main(void)

{

    scanf("%d",&N);

    dfs(0,0);

    printf("%d\n",count);

    return 0;

}

void dfs(long long nextNum,int flag357)

{

    if(nextNum<=N)

    {

        if(flag357==7)    // 07 is BIN 111

            count++;

        dfs(nextNum*10+3,flag357|1); // BIN 001

        dfs(nextNum*10+5,flag357|2); // BIN 010

        dfs(nextNum*10+7,flag357|4); // BIN 100

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<stdlib.h>

#include<string>

using namespace std;

string str;

int num = 0;

void DFS(int flag3, int flag5, int flag7, string s)

{

	if (s.size() == str.size())

	{

		if (s > str)

			return;

	}

	else if (s.size() > str.size())

		return;

	if (flag3 == 1 && flag5 == 1 && flag7 == 1)

		num++;

	DFS(1, flag5, flag7, s + '3');

	DFS(flag3, 1, flag7, s + '5');

	DFS(flag3, flag5, 1, s + '7');

}

int main()

{

	cin >> str;

	string s = "";

	DFS(0, 0, 0, s);

	cout << num << endl;

	system("pause");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

int N,count=0;

void dfs(long long,int);

int main(void)

{

    scanf("%d",&N);

    dfs(0,0);

    printf("%d\n",count);

    return 0;

}

void dfs(long long nextNum,int flag357)

{

    if(nextNum<=N)

    {

        if(flag357==7)    // 07 is BIN 111

            count++;

        dfs(nextNum*10+3,flag357|1); // BIN 001

        dfs(nextNum*10+5,flag357|2); // BIN 010

        dfs(nextNum*10+7,flag357|4); // BIN 100

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int cnt = 0, N;



bool chk(ll n)

{

    int a[10] = {};

    while (n) {

        int lst = n % 10;

        a[lst]++;

        n /= 10;

    }



    if (a[3] && a[5] && a[7]) return true;

    return false;

}



void dfs(ll n)

{

    if (n > N) return;

    if (chk(n)) cnt++;

    dfs(n*10 + 3);

    dfs(n*10 + 5);

    dfs(n*10 + 7);

}



int main()

{

    cin >> N;

    dfs(0);

    cout << cnt << "\n";

}


// Optimized solution to the same problem (faster):
#include <cstdio>

int N,count=0;

void dfs(long long,int);

int main(void)

{

    scanf("%d",&N);

    dfs(0,0);

    printf("%d\n",count);

    return 0;

}

void dfs(long long nextNum,int flag357)

{

    if(nextNum<=N)

    {

        if(flag357==7)    // 07 is BIN 111

            count++;

        dfs(nextNum*10+3,flag357|1); // BIN 001

        dfs(nextNum*10+5,flag357|2); // BIN 010

        dfs(nextNum*10+7,flag357|4); // BIN 100

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<queue>

#include<string>

using namespace std;



int ans;

int arr[3]={3,5,7};



bool func(int data){

	string s;

	while(data){

		s=s+(char)(data%10+'0');

		data/=10;

	}

	if(s.find('3')!=string::npos&&s.find('5')!=string::npos&&s.find('7')!=string::npos){

		return true;

	}

	return false;

}



void BFS(int t){

	if(t<357){

		ans=0;

		return;

	}

	queue<int> myque;

	myque.push(0);

	while(!myque.empty()){

		int acc=myque.front();

		if(acc>t||acc>77777777){

			return;

		}

		myque.pop();

		for(int i=0;i<3;i++){

			int temp=acc*10+arr[i];

			if(temp>t){

				break;

			}

			if(func(temp)){

				ans++;

			}

			myque.push(temp);

		}

	}

}



int main(){

	int t;

	cin>>t;

	ans=0;

	BFS(t);

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

int N,count=0;

void dfs(long long,int);

int main(void)

{

    scanf("%d",&N);

    dfs(0,0);

    printf("%d\n",count);

    return 0;

}

void dfs(long long nextNum,int flag357)

{

    if(nextNum<=N)

    {

        if(flag357==7)    // 07 is BIN 111

            count++;

        dfs(nextNum*10+3,flag357|1); // BIN 001

        dfs(nextNum*10+5,flag357|2); // BIN 010

        dfs(nextNum*10+7,flag357|4); // BIN 100

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int , int> P;

typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;

const ll LL_INF = 9223372036854775807;



bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)

{

       return a.second<b.second;

}

 

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)

{

       return a.second>b.second;

}

 

string s;

ll n;

int a[11];

ll ans;





int ar[3] = {3,5,7};

void calc(ll num, int f1, int f2, int f3){

    int nn;

    string st;

    for(int i = 0; i < 3; i++){

        nn = num*10+ar[i];

        if(i == 0)  f1++;

        else if(i == 1) f2++;

        else   f3++;



        st = to_string(nn);

        if(st.length() > 9) return;



        if(f1 != 0 && f2 != 0 && f3 != 0){

            if(nn <= n){

                ++ans;

            //  cout << nn << endl;

                calc(nn,f1,f2,f3);

            }

        }

        else{

            calc(nn,f1,f2,f3);

        }

        if(i == 0)  f1--;

        else if(i == 1) f2--;

        else   f3--;

    }

    return;

}



int main(){

    cin >> n;

    int f1=0,f2=0,f3=0;

    calc(3,1,0,0);

    calc(5,0,1,0);

    calc(7,0,0,1);



    cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int , int> P;

typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;

const ll LL_INF = 9223372036854775807;



bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)

{

       return a.second<b.second;

}

 

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)

{

       return a.second>b.second;

}

 

ll n;

ll ans;



void solve(ll val, bool f1, bool f2, bool f3){

    if(val <= n){

        if(f1 && f2 && f3)  ++ans;

        solve(val*10+7,true,f2,f3);

        solve(val*10+5,f1,true,f3);

        solve(val*10+3,f1,f2,true);

    }

}





int main(){

    cin >> n;

    solve(7,true,false,false);

    solve(5,false,true,false);

    solve(3,false,false,true);



    cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

int M=0;

int n;

int A[1000];

void dfs(int k){

	int f3=0,f5=0,f7=0;

	long long num=0;

	for(int i=0;i<k;i++){

		num=num*10+A[i];

		if(A[i]==3)

			f3=1;

		else if(A[i]==5)

			f5=1;

		else if(A[i]==7)

			f7=1;

	}

	if(num>n) return;

	if(f3*f5*f7==1)

		M++;

	A[k]=3;

	dfs(k+1);

	A[k]=5;

	dfs(k+1);

	A[k]=7;

	dfs(k+1);

}

int main(){

	cin>>n;

	dfs(0);

	cout<<M;

	return 0;

}

// Optimized solution to the same problem (faster):
#define _CRT_SECURE_NO_DEPRECATE

#include<cstdio>

using namespace std;

typedef long long int ll;

int ans = 0;

ll T;

void DFS(ll n,bool r3,bool r5,bool r7) {

	if (n <= T) {

		if (r3&&r5&&r7)

			ans++;

		DFS(n * 10 + 3, true, r5, r7);

		DFS(n * 10 + 5, r3, true, r7);

		DFS(n * 10 + 7, r3, r5, true);

	}

}



int main() {

	scanf("%ld", &T);

	DFS(0,false,false,false);

	printf("%d\n", ans);

	getchar();getchar();

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include<cstring>



using namespace std;

int len,ans = 0 ,res=0;

char d[3]={'3','5','7'},x[11];

    int  num;

bool isValid(char a[])

{

    int cnt[11]={0};

    for(int i=0;i<strlen(a);i++)

    {

        cnt[a[i]-'0']++;

    }



    if(cnt[3] >= 1 && cnt[5] >= 1 && cnt[7] >= 1 &&  cnt[3] + cnt[5] + cnt[7] == strlen(a))

    {

        if(atoi(a) <= num)

        return true;

    }

    return false;

}



void dfs(int pos ,int len ,char  a[] )

{

    if(pos == len )

    {

        a[len]='\0';

        if(isValid(a))

        {

            res++;

        }

        return ;

    }

        a[pos] = '3';

        dfs(pos+1,len,a);



        a[pos] = '5';

        dfs(pos+1,len,a);



        a[pos] = '7';

        dfs(pos+1,len,a);

}

int main()

{



    int i,j,k;

    char str[11];

     scanf("%s",&str);

    num = atoi(str);

    len = strlen(str);



    for(i = 3;i<=len;i++)

        dfs(0,i,x);

    cout<<res;



    return 0;

}


// Optimized solution to the same problem (faster):
#define _CRT_SECURE_NO_DEPRECATE

#include<cstdio>

using namespace std;

typedef long long int ll;

int ans = 0;

ll T;

void DFS(ll n,bool r3,bool r5,bool r7) {

	if (n <= T) {

		if (r3&&r5&&r7)

			ans++;

		DFS(n * 10 + 3, true, r5, r7);

		DFS(n * 10 + 5, r3, true, r7);

		DFS(n * 10 + 7, r3, r5, true);

	}

}



int main() {

	scanf("%ld", &T);

	DFS(0,false,false,false);

	printf("%d\n", ans);

	getchar();getchar();

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

using ll = long long;



int n, cnt;



void dfs(ll x, int f) {

    if(x > n) return;

    if(f == 7) cnt++;

    dfs(x * 10 + 3, f | 1);

    dfs(x * 10 + 5, f | 2);

    dfs(x * 10 + 7, f | 4);

}



int main() {

    cin >> n;

    dfs(0, 0);

    cout << cnt << endl;

}

// Optimized solution to the same problem (faster):
#define _CRT_SECURE_NO_DEPRECATE

#include<cstdio>

using namespace std;

typedef long long int ll;

int ans = 0;

ll T;

void DFS(ll n,bool r3,bool r5,bool r7) {

	if (n <= T) {

		if (r3&&r5&&r7)

			ans++;

		DFS(n * 10 + 3, true, r5, r7);

		DFS(n * 10 + 5, r3, true, r7);

		DFS(n * 10 + 7, r3, r5, true);

	}

}



int main() {

	scanf("%ld", &T);

	DFS(0,false,false,false);

	printf("%d\n", ans);

	getchar();getchar();

	return 0;

}

// Fastest known solution for this problem: