#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

const int N = 15;

char a[N];
int ans = 0;
int tr[N],cnt;
int st[N];

void dfs(int num)
{
	if(num == 4)
	{
		bool fl = true;
		for(int i = 1;i <= cnt;i++)
			if(st[tr[i]] == 0)
			{
				fl = false;
				break;
			}
		if(fl) ans++;
		return;
	}
	
	for(int i = 0;i < 10;i++)
	{
		if(a[i] == 'x') continue;
		st[i]++;
		dfs(num + 1);
		st[i]--;
	}
	
}

int main()
{
	scanf("%s",a);
	for(int i = 0;i < 10;i++)
	    if(a[i] == 'o') 
	        tr[++cnt] = i;
	
	if(cnt > 4) 
	{
		printf("0");
		return 0;
	}
	
	dfs(0);
	
	printf("%d",ans);
	
	return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


int main() {
  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i){
    int judge = 0;
    int i2 = i;
    while (i2){
      if (i2%10 == 7) {
        judge = 1;
        break;
      }
      i2 /= 10;
    }
    i2 = i;
    while (i2){
      if (i2 % 8 == 7) {
        judge = 1;
        break;
      }
      i2 /= 8;
    }
    if (judge == 1) continue;
    ans++;
  }
  cout << ans << endl;
}
