stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <cmath>

#include <algorithm>

#include <cstring>

#include <iostream>

#include <cstdio>

#include <ctype.h>

#include <string>

#include <vector>

#include <map>

#include <set>

#include <unordered_map>

#define INF 0x3fffffff

#define DEBUG 1

#define MAXSIZE 100005

using namespace std;

typedef long long LL;





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

int b[10] = { 0 };

LL com(int k[]) {

	LL ans = 0;

	int i = 0;

	LL tem = 1;

	while (k[i] != 0) {

		ans += k[i] * tem;

		tem *= 10;

		i++;

	}

	return ans;

}

bool judge(int k[]) {

	int ha[10] = { 0 };

	int i = 0;

	while (k[i] != 0) ha[k[i++]]++;

	return ha[3] && ha[5] && ha[7];

}

void jw(int k[]) {

	if (k[0] != 7) {

		if (k[0] == 3) k[0] = 5;

		else if (k[0] == 5) k[0] = 7;

		return ;

	}

	else {

		k[0] = 3;

		int i = 1;

		while (k[i] == 7) {

			k[i++] = 3;

		}

		if (k[i] == 3) k[i] = 5;

		else if (k[i] == 5) k[i] = 7;

		else k[i] = 3;

	}

}

int main() {

	int n;

	scanf("%d", &n);

	b[3] = 0; b[5] = 1; b[7] = 2;

	int k[11] = {0};

	k[0] = 7; k[1] = 5; k[2] = {3};

	int ans = 0;

	while (com(k) <= n) {

		ans++;

		jw(k);

		while (!judge(k)) jw(k);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.9905279018061055x):
#include<cstdio>

int count=0;

int T;

void dfs(long long n,char flag357)

{

	if(n<=T)

	{

		if(flag357==07)

		count++;

		dfs(n*10+3,flag357|01);

		dfs(n*10+5,flag357|02);

		dfs(n*10+7,flag357|04);

	}

}



int main()

{

	char flag357;

	scanf("%d",&T);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include <stack>

#include<cstdio>

#include<algorithm>

#include<string.h>

#include<set>

#include<map>

#include<cmath>

#define MAXN 51

#include<utility>

#define DEBUG 0



using namespace std;

typedef long long ll;

ll M;

ll c=0;

ll a[3]={3,5,7};

ll vis[3]={0};

void dfs(ll n,ll cur)

{

    if(n>M) return ;

    else

    {

        if(n>=357&&vis[0]&&vis[1]&&vis[2]) c++;

        ll p=1;

        for(int i=0;i<cur;i++) p*=10;

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

            {

                vis[i]++;

                dfs(n*10+a[i],cur+1);

                vis[i]--;

            }

    }

}

int main()

{

    #if DEBUG

    freopen("in.txt","r",stdin);

    #endif // DEBUG

    scanf("%lld",&M);

    vis[0]=1;

    dfs(3,1);

    vis[0]=0;

    vis[1]=1;

    dfs(5,1);

    vis[1]=0;

    vis[2]=1;

    dfs(7,1);

    vis[2]=0;



    printf("%lld\n",c);

    #if DEBUG

    fclose(stdin);

    #endif // DEBUG



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.798947533671934x):
#include<cstdio>

int count=0;

int T;

void dfs(long long n,char flag357)

{

	if(n<=T)

	{

		if(flag357==07)

		count++;

		dfs(n*10+3,flag357|01);

		dfs(n*10+5,flag357|02);

		dfs(n*10+7,flag357|04);

	}

}



int main()

{

	char flag357;

	scanf("%d",&T);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include<cstdio>

#include <string>

#include <map>

#include <algorithm>

using namespace std;



long T;

int x = 0;

string a = "3";

string b = "5";

string c = "7";



void upnumber(long n)

{

	if (n <= T)

	{

		string N = to_string(n);

		if (N.find(a) != string::npos && N.find(b) != string::npos && N.find(c) != string::npos)

		{

			x++;

		}

		upnumber(n * 10 + 3);

		upnumber(n * 10 + 5);

		upnumber(n * 10 + 7);

	}

}



int main()

{

	cin >> T;

	upnumber(0);

	cout << x;



}

// Faster C++ solution for the same problem (measured speedup: 8.183167672167327x):
#include<cstdio>

int count=0;

int T;

void dfs(long long n,char flag357)

{

	if(n<=T)

	{

		if(flag357==07)

		count++;

		dfs(n*10+3,flag357|01);

		dfs(n*10+5,flag357|02);

		dfs(n*10+7,flag357|04);

	}

}



int main()

{

	char flag357;

	scanf("%d",&T);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <algorithm>



using namespace std;



long long T, ans = 0;

int len;

void BS(int val, int len);

bool isX(long long a);



bool isX(long long a)

{

    int flag3 = 0;

    int flag5 = 0;

    int flag7 = 0;

    while(a != 0)

    {

        if(a % 10 == 3)

            flag3 = 1;

        else if(a % 10 == 5)

            flag5 = 1;

        else if(a % 10 == 7)

            flag7 = 1;

        else

            return false;

        a /= 10;

    }

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

        return true;

    else

        return false;

}

void BS(int val, int step)

{

    if(step == len)

    {

        if(val <= T && isX(val))

        {

            ans++;

        }

        return;

    }

    else if(step < len)

    {

        if(val <= T && isX(val))

            ans++;

    }

    for(int i = 3; i <= 7; i = i + 2)

    {

        BS(val * 10 + i, step + 1);

    }

}

int main()

{

    scanf("%lld", &T);

    char s[15];

    sprintf(s, "%d", T);

    len = strlen(s);

    //printf("%d", len);

    //if(isX(T))

       // printf("!!!");

    ans = 0;

    BS(0, 0);

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

}


// Faster C++ solution for the same problem (measured speedup: 5.857487736607628x):
#include<cstdio>

int count=0;

int T;

void dfs(long long n,char flag357)

{

	if(n<=T)

	{

		if(flag357==07)

		count++;

		dfs(n*10+3,flag357|01);

		dfs(n*10+5,flag357|02);

		dfs(n*10+7,flag357|04);

	}

}



int main()

{

	char flag357;

	scanf("%d",&T);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

using ll = long long;



int num[12], cnt;



pair<ll, int> xx(int x) {

    ll ans = 0, f = 0;

    cnt = 0;

    while(x) {

        int c = x % 4; x /= 4;

        if (!c) { f |= 8; num[cnt++] = 0; }

        if (c == 1) { f |= 1; num[cnt++] = 3; }

        if (c == 2) { f |= 2; num[cnt++] = 5; }

        if (c == 3) { f |= 4; num[cnt++] = 7; }

    }

    for(int i = cnt - 1; ~i; --i) ans = ans * 10 + num[i];

    return make_pair(ans, f);

}



int main() {

    ios::sync_with_stdio(0);

    int n, ans = 0;

    cin >> n;

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

        pair<ll, int> c = xx(i);

        if(c.first > n) break;

        if(c.second == 7) ans++;

    }



    cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 10.751639045990418x):
#include<cstdio>

int count=0;

int T;

void dfs(long long n,char flag357)

{

	if(n<=T)

	{

		if(flag357==07)

		count++;

		dfs(n*10+3,flag357|01);

		dfs(n*10+5,flag357|02);

		dfs(n*10+7,flag357|04);

	}

}



int main()

{

	char flag357;

	scanf("%d",&T);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

long long a[233];

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

int vis[3];

int ans;

long long t ;

void dfs(int i)

{

    long long  num=0;

    memset(vis,0,sizeof(vis));

    for(int j=1;j<i;j++)

    {

        num=num*10+a[j];

        if(a[j]==3) vis[0]=1;

        if(a[j]==5) vis[1]=1;

        if(a[j]==7) vis[2]=1;

    }



    int flag= vis[0]*vis[1]*vis[2];

    if(num > t ) return ;



    if(flag) {ans++;

    }

    for(int j = 0 ;j<3;j++)

    {

        a[i]=b[j];

        dfs(i+1);

    }

}

int main()

{



  scanf("%d",&t);

   ans=0;

  dfs(1);



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

}


// Faster C++ solution for the same problem (measured speedup: 6.654451891848748x):
#include<stdio.h>

int N;int cnt=0;

void dfs(long long num,unsigned char flag357);

int main(){

	scanf("%d",&N);

	dfs(0,0);

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

	return 0;

}



void dfs(long long num,unsigned char flag357){

	if(num<=N){

		if(flag357==07)

			cnt++;

		dfs(num*10+3,flag357|01);

		dfs(num*10+5,flag357|02);

		dfs(num*10+7,flag357|04);

	}

}
// Slower C++ solution:
#include <cmath>

#include <algorithm>

#include <cstring>

#include <iostream>

#include <cstdio>

#include <ctype.h>

#include <string>

#include <vector>

#include <map>

#include <set>

#include <unordered_map>

#define INF 0x3fffffff

#define DEBUG 1

#define MAXSIZE 100005

using namespace std;

typedef long long LL;





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

int b[10] = { 0 };

LL com(int k[]) {

	LL ans = 0;

	int i = 0;

	LL tem = 1;

	while (k[i] != 0) {

		ans += k[i] * tem;

		tem *= 10;

		i++;

	}

	return ans;

}

bool judge(int k[]) {

	int ha[10] = { 0 };

	int i = 0;

	while (k[i] != 0) ha[k[i++]]++;

	return ha[3] && ha[5] && ha[7];

}

void jw(int k[]) {

	if (k[0] != 7) {

		if (k[0] == 3) k[0] = 5;

		else if (k[0] == 5) k[0] = 7;

		return ;

	}

	else {

		k[0] = 3;

		int i = 1;

		while (k[i] == 7) {

			k[i++] = 3;

		}

		if (k[i] == 3) k[i] = 5;

		else if (k[i] == 5) k[i] = 7;

		else k[i] = 3;

	}

}

int main() {

	int n;

	scanf("%d", &n);

	b[3] = 0; b[5] = 1; b[7] = 2;

	int k[11] = {0};

	k[0] = 7; k[1] = 5; k[2] = {3};

	int ans = 0;

	while (com(k) <= n) {

		ans++;

		jw(k);

		while (!judge(k)) jw(k);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.9905279018061055x):
#include<stdio.h>

int N;int cnt=0;

void dfs(long long num,unsigned char flag357);

int main(){

	scanf("%d",&N);

	dfs(0,0);

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

	return 0;

}



void dfs(long long num,unsigned char flag357){

	if(num<=N){

		if(flag357==07)

			cnt++;

		dfs(num*10+3,flag357|01);

		dfs(num*10+5,flag357|02);

		dfs(num*10+7,flag357|04);

	}

}
// Slower C++ solution:
#include<iostream>

#include <stack>

#include<cstdio>

#include<algorithm>

#include<string.h>

#include<set>

#include<map>

#include<cmath>

#define MAXN 51

#include<utility>

#define DEBUG 0



using namespace std;

typedef long long ll;

ll M;

ll c=0;

ll a[3]={3,5,7};

ll vis[3]={0};

void dfs(ll n,ll cur)

{

    if(n>M) return ;

    else

    {

        if(n>=357&&vis[0]&&vis[1]&&vis[2]) c++;

        ll p=1;

        for(int i=0;i<cur;i++) p*=10;

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

            {

                vis[i]++;

                dfs(n*10+a[i],cur+1);

                vis[i]--;

            }

    }

}

int main()

{

    #if DEBUG

    freopen("in.txt","r",stdin);

    #endif // DEBUG

    scanf("%lld",&M);

    vis[0]=1;

    dfs(3,1);

    vis[0]=0;

    vis[1]=1;

    dfs(5,1);

    vis[1]=0;

    vis[2]=1;

    dfs(7,1);

    vis[2]=0;



    printf("%lld\n",c);

    #if DEBUG

    fclose(stdin);

    #endif // DEBUG



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.798947533671934x):
#include<stdio.h>

int N;int cnt=0;

void dfs(long long num,unsigned char flag357);

int main(){

	scanf("%d",&N);

	dfs(0,0);

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

	return 0;

}



void dfs(long long num,unsigned char flag357){

	if(num<=N){

		if(flag357==07)

			cnt++;

		dfs(num*10+3,flag357|01);

		dfs(num*10+5,flag357|02);

		dfs(num*10+7,flag357|04);

	}

}
// Slower C++ solution:
#include <iostream>

#include<cstdio>

#include <string>

#include <map>

#include <algorithm>

using namespace std;



long T;

int x = 0;

string a = "3";

string b = "5";

string c = "7";



void upnumber(long n)

{

	if (n <= T)

	{

		string N = to_string(n);

		if (N.find(a) != string::npos && N.find(b) != string::npos && N.find(c) != string::npos)

		{

			x++;

		}

		upnumber(n * 10 + 3);

		upnumber(n * 10 + 5);

		upnumber(n * 10 + 7);

	}

}



int main()

{

	cin >> T;

	upnumber(0);

	cout << x;



}

// Faster C++ solution for the same problem (measured speedup: 8.183167672167327x):
#include<stdio.h>

int N;int cnt=0;

void dfs(long long num,unsigned char flag357);

int main(){

	scanf("%d",&N);

	dfs(0,0);

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

	return 0;

}



void dfs(long long num,unsigned char flag357){

	if(num<=N){

		if(flag357==07)

			cnt++;

		dfs(num*10+3,flag357|01);

		dfs(num*10+5,flag357|02);

		dfs(num*10+7,flag357|04);

	}

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <algorithm>



using namespace std;



long long T, ans = 0;

int len;

void BS(int val, int len);

bool isX(long long a);



bool isX(long long a)

{

    int flag3 = 0;

    int flag5 = 0;

    int flag7 = 0;

    while(a != 0)

    {

        if(a % 10 == 3)

            flag3 = 1;

        else if(a % 10 == 5)

            flag5 = 1;

        else if(a % 10 == 7)

            flag7 = 1;

        else

            return false;

        a /= 10;

    }

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

        return true;

    else

        return false;

}

void BS(int val, int step)

{

    if(step == len)

    {

        if(val <= T && isX(val))

        {

            ans++;

        }

        return;

    }

    else if(step < len)

    {

        if(val <= T && isX(val))

            ans++;

    }

    for(int i = 3; i <= 7; i = i + 2)

    {

        BS(val * 10 + i, step + 1);

    }

}

int main()

{

    scanf("%lld", &T);

    char s[15];

    sprintf(s, "%d", T);

    len = strlen(s);

    //printf("%d", len);

    //if(isX(T))

       // printf("!!!");

    ans = 0;

    BS(0, 0);

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

}


// Faster C++ solution for the same problem (measured speedup: 5.857487736607628x):
#include<stdio.h>

int N;int cnt=0;

void dfs(long long num,unsigned char flag357);

int main(){

	scanf("%d",&N);

	dfs(0,0);

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

	return 0;

}



void dfs(long long num,unsigned char flag357){

	if(num<=N){

		if(flag357==07)

			cnt++;

		dfs(num*10+3,flag357|01);

		dfs(num*10+5,flag357|02);

		dfs(num*10+7,flag357|04);

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

using ll = long long;



int num[12], cnt;



pair<ll, int> xx(int x) {

    ll ans = 0, f = 0;

    cnt = 0;

    while(x) {

        int c = x % 4; x /= 4;

        if (!c) { f |= 8; num[cnt++] = 0; }

        if (c == 1) { f |= 1; num[cnt++] = 3; }

        if (c == 2) { f |= 2; num[cnt++] = 5; }

        if (c == 3) { f |= 4; num[cnt++] = 7; }

    }

    for(int i = cnt - 1; ~i; --i) ans = ans * 10 + num[i];

    return make_pair(ans, f);

}



int main() {

    ios::sync_with_stdio(0);

    int n, ans = 0;

    cin >> n;

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

        pair<ll, int> c = xx(i);

        if(c.first > n) break;

        if(c.second == 7) ans++;

    }



    cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 10.751639045990418x):
#include<stdio.h>

int N;int cnt=0;

void dfs(long long num,unsigned char flag357);

int main(){

	scanf("%d",&N);

	dfs(0,0);

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

	return 0;

}



void dfs(long long num,unsigned char flag357){

	if(num<=N){

		if(flag357==07)

			cnt++;

		dfs(num*10+3,flag357|01);

		dfs(num*10+5,flag357|02);

		dfs(num*10+7,flag357|04);

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

long long a[233];

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

int vis[3];

int ans;

long long t ;

void dfs(int i)

{

    long long  num=0;

    memset(vis,0,sizeof(vis));

    for(int j=1;j<i;j++)

    {

        num=num*10+a[j];

        if(a[j]==3) vis[0]=1;

        if(a[j]==5) vis[1]=1;

        if(a[j]==7) vis[2]=1;

    }



    int flag= vis[0]*vis[1]*vis[2];

    if(num > t ) return ;



    if(flag) {ans++;

    }

    for(int j = 0 ;j<3;j++)

    {

        a[i]=b[j];

        dfs(i+1);

    }

}

int main()

{



  scanf("%d",&t);

   ans=0;

  dfs(1);



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

}


// Faster C++ solution for the same problem (measured speedup: 6.654451891848748x):
#include<cstdio>

int n,count=0;

void dfs(long long nextnum,unsigned char flag357)

{

	if(nextnum<=n)

	{

		if(flag357==7)//7的二进制位是111

			count++;

		dfs(nextnum*10+3,flag357|1);//1的二进制位001

		dfs(nextnum*10+5,flag357|2);//2的二进制位010

		dfs(nextnum*10+7,flag357|4);//4的二进制位100

	}

}

int main()

{

	scanf("%d",&n);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include <cmath>

#include <algorithm>

#include <cstring>

#include <iostream>

#include <cstdio>

#include <ctype.h>

#include <string>

#include <vector>

#include <map>

#include <set>

#include <unordered_map>

#define INF 0x3fffffff

#define DEBUG 1

#define MAXSIZE 100005

using namespace std;

typedef long long LL;





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

int b[10] = { 0 };

LL com(int k[]) {

	LL ans = 0;

	int i = 0;

	LL tem = 1;

	while (k[i] != 0) {

		ans += k[i] * tem;

		tem *= 10;

		i++;

	}

	return ans;

}

bool judge(int k[]) {

	int ha[10] = { 0 };

	int i = 0;

	while (k[i] != 0) ha[k[i++]]++;

	return ha[3] && ha[5] && ha[7];

}

void jw(int k[]) {

	if (k[0] != 7) {

		if (k[0] == 3) k[0] = 5;

		else if (k[0] == 5) k[0] = 7;

		return ;

	}

	else {

		k[0] = 3;

		int i = 1;

		while (k[i] == 7) {

			k[i++] = 3;

		}

		if (k[i] == 3) k[i] = 5;

		else if (k[i] == 5) k[i] = 7;

		else k[i] = 3;

	}

}

int main() {

	int n;

	scanf("%d", &n);

	b[3] = 0; b[5] = 1; b[7] = 2;

	int k[11] = {0};

	k[0] = 7; k[1] = 5; k[2] = {3};

	int ans = 0;

	while (com(k) <= n) {

		ans++;

		jw(k);

		while (!judge(k)) jw(k);

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.9905279018061055x):
#include<cstdio>

int n,count=0;

void dfs(long long nextnum,unsigned char flag357)

{

	if(nextnum<=n)

	{

		if(flag357==7)//7的二进制位是111

			count++;

		dfs(nextnum*10+3,flag357|1);//1的二进制位001

		dfs(nextnum*10+5,flag357|2);//2的二进制位010

		dfs(nextnum*10+7,flag357|4);//4的二进制位100

	}

}

int main()

{

	scanf("%d",&n);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include <stack>

#include<cstdio>

#include<algorithm>

#include<string.h>

#include<set>

#include<map>

#include<cmath>

#define MAXN 51

#include<utility>

#define DEBUG 0



using namespace std;

typedef long long ll;

ll M;

ll c=0;

ll a[3]={3,5,7};

ll vis[3]={0};

void dfs(ll n,ll cur)

{

    if(n>M) return ;

    else

    {

        if(n>=357&&vis[0]&&vis[1]&&vis[2]) c++;

        ll p=1;

        for(int i=0;i<cur;i++) p*=10;

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

            {

                vis[i]++;

                dfs(n*10+a[i],cur+1);

                vis[i]--;

            }

    }

}

int main()

{

    #if DEBUG

    freopen("in.txt","r",stdin);

    #endif // DEBUG

    scanf("%lld",&M);

    vis[0]=1;

    dfs(3,1);

    vis[0]=0;

    vis[1]=1;

    dfs(5,1);

    vis[1]=0;

    vis[2]=1;

    dfs(7,1);

    vis[2]=0;



    printf("%lld\n",c);

    #if DEBUG

    fclose(stdin);

    #endif // DEBUG



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.798947533671934x):
#include<cstdio>

int n,count=0;

void dfs(long long nextnum,unsigned char flag357)

{

	if(nextnum<=n)

	{

		if(flag357==7)//7的二进制位是111

			count++;

		dfs(nextnum*10+3,flag357|1);//1的二进制位001

		dfs(nextnum*10+5,flag357|2);//2的二进制位010

		dfs(nextnum*10+7,flag357|4);//4的二进制位100

	}

}

int main()

{

	scanf("%d",&n);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include<cstdio>

#include <string>

#include <map>

#include <algorithm>

using namespace std;



long T;

int x = 0;

string a = "3";

string b = "5";

string c = "7";



void upnumber(long n)

{

	if (n <= T)

	{

		string N = to_string(n);

		if (N.find(a) != string::npos && N.find(b) != string::npos && N.find(c) != string::npos)

		{

			x++;

		}

		upnumber(n * 10 + 3);

		upnumber(n * 10 + 5);

		upnumber(n * 10 + 7);

	}

}



int main()

{

	cin >> T;

	upnumber(0);

	cout << x;



}

// Faster C++ solution for the same problem (measured speedup: 8.183167672167327x):
#include<cstdio>

int n,count=0;

void dfs(long long nextnum,unsigned char flag357)

{

	if(nextnum<=n)

	{

		if(flag357==7)//7的二进制位是111

			count++;

		dfs(nextnum*10+3,flag357|1);//1的二进制位001

		dfs(nextnum*10+5,flag357|2);//2的二进制位010

		dfs(nextnum*10+7,flag357|4);//4的二进制位100

	}

}

int main()

{

	scanf("%d",&n);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <algorithm>



using namespace std;



long long T, ans = 0;

int len;

void BS(int val, int len);

bool isX(long long a);



bool isX(long long a)

{

    int flag3 = 0;

    int flag5 = 0;

    int flag7 = 0;

    while(a != 0)

    {

        if(a % 10 == 3)

            flag3 = 1;

        else if(a % 10 == 5)

            flag5 = 1;

        else if(a % 10 == 7)

            flag7 = 1;

        else

            return false;

        a /= 10;

    }

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

        return true;

    else

        return false;

}

void BS(int val, int step)

{

    if(step == len)

    {

        if(val <= T && isX(val))

        {

            ans++;

        }

        return;

    }

    else if(step < len)

    {

        if(val <= T && isX(val))

            ans++;

    }

    for(int i = 3; i <= 7; i = i + 2)

    {

        BS(val * 10 + i, step + 1);

    }

}

int main()

{

    scanf("%lld", &T);

    char s[15];

    sprintf(s, "%d", T);

    len = strlen(s);

    //printf("%d", len);

    //if(isX(T))

       // printf("!!!");

    ans = 0;

    BS(0, 0);

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

}


// Faster C++ solution for the same problem (measured speedup: 5.857487736607628x):
#include<cstdio>

int n,count=0;

void dfs(long long nextnum,unsigned char flag357)

{

	if(nextnum<=n)

	{

		if(flag357==7)//7的二进制位是111

			count++;

		dfs(nextnum*10+3,flag357|1);//1的二进制位001

		dfs(nextnum*10+5,flag357|2);//2的二进制位010

		dfs(nextnum*10+7,flag357|4);//4的二进制位100

	}

}

int main()

{

	scanf("%d",&n);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

using ll = long long;



int num[12], cnt;



pair<ll, int> xx(int x) {

    ll ans = 0, f = 0;

    cnt = 0;

    while(x) {

        int c = x % 4; x /= 4;

        if (!c) { f |= 8; num[cnt++] = 0; }

        if (c == 1) { f |= 1; num[cnt++] = 3; }

        if (c == 2) { f |= 2; num[cnt++] = 5; }

        if (c == 3) { f |= 4; num[cnt++] = 7; }

    }

    for(int i = cnt - 1; ~i; --i) ans = ans * 10 + num[i];

    return make_pair(ans, f);

}



int main() {

    ios::sync_with_stdio(0);

    int n, ans = 0;

    cin >> n;

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

        pair<ll, int> c = xx(i);

        if(c.first > n) break;

        if(c.second == 7) ans++;

    }



    cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 10.751639045990418x):
#include<cstdio>

int n,count=0;

void dfs(long long nextnum,unsigned char flag357)

{

	if(nextnum<=n)

	{

		if(flag357==7)//7的二进制位是111

			count++;

		dfs(nextnum*10+3,flag357|1);//1的二进制位001

		dfs(nextnum*10+5,flag357|2);//2的二进制位010

		dfs(nextnum*10+7,flag357|4);//4的二进制位100

	}

}

int main()

{

	scanf("%d",&n);

	dfs(0,0);

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

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define all(v)			((v).begin()), ((v).end())

#define sz(v)			((int)((v).size()))

#define clr(v, d)		memset(v, d, sizeof(v))

#define rep(i, v)		for(int i=0;i<sz(v);++i)

#define lp(i, n)		for(int i=0;i<(int)(n);++i)

#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)

#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;

typedef pair<int,int> pi;

vector<vector<int>> v(100009);

bool vis[100009];

long long n;

int dfs(long long a,bool n3,bool n5,bool n7)

{

    if(a>n)

        return 0;

    int x=0;

    if(n3&&n5&&n7)

        x++;

    x+=dfs(a*10+3,1,n5,n7);

    x+=dfs(a*10+5,n3,1,n7);

    x+=dfs(a*10+7,n3,n5,1);

    return x;

}

int main() {

#ifndef ONLINE_JUDGE

	//freopen("test.txt", "rt", stdin);

#endif

    cin>>n;

    cout<<dfs(0,0,0,0);



}


// Faster C++ solution for the same problem (measured speedup: 3.4906952192923546x):
#include<iostream>

using namespace std;

int count=0;

long long n;

void DFS(long long num,unsigned char flag357){

	if(num<=n){

		if(flag357==07){

		    count++;

		}

	DFS(num*10+3,flag357|01);

	DFS(num*10+5,flag357|02);

	DFS(num*10+7,flag357|04);

	}

}

int main(){

	cin>>n;

	DFS(0,0);

	cout<<count;

}