#include <bits/stdc++.h>
using namespace std;
int num[10] = {0}, n;
int memo[10][2][10][10][10] = {0};
int dfs(int kt, int sr, int c3, int c5, int c7) {
  if (kt >= n && c3 > 0 && c5 > 0 && c7 > 0) return 1;
  if (kt >= n) return 0;
  if (sr == 0) {
    int res = 0;
    res += dfs(kt + 1, sr, c3 + 1, c5, c7);
    res += dfs(kt + 1, sr, c3, c5 + 1, c7);
    res += dfs(kt + 1, sr, c3, c5, c7 + 1);
    return res;
  } else {
    int sev[] = {3, 5, 7}, ret = 0;
    for (int i = 0; i < 3; i++) {
      bool f = true;
      int gr = 0;
      if (sev[i] > num[kt]) f = false;
      if (sev[i] == num[kt]) gr++;
      if (f) {
        if (i == 0) ret += dfs(kt + 1, gr, c3 + 1, c5, c7);
        if (i == 1) ret += dfs(kt + 1, gr, c3, c5 + 1, c7);
        if (i == 2) ret += dfs(kt + 1, gr, c3, c5, c7 + 1);
      }
    }
    return ret;
  }
}
int main() {
  string s;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) num[i] = s[i] - '0';
  cout << dfs(0, 1, 0, 0, 0) << endl;
}
