#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, a, b, c, ans = 0;
  set<char> pt;
  cin >> n;
  s = to_string(n);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= '9')
      s[i] = '7';
    else if (s[i] >= '5')
      s[i] = '5';
    else if (s[i] >= '3')
      s[i] = '3';
  }
  a = 0;
  for (int i = 0; i < s.size(); i++) {
    a = a * 4;
    if (s[i] == '7') {
      a += 3;
    } else if (s[i] == '5') {
      a += 2;
    } else if (s[i] == '3') {
      a += 1;
    }
  }
  for (int i = 0; i <= a; i++) {
    pt.clear();
    b = i;
    while (b > 0) {
      c = b % 4;
      pt.insert(c);
      b = b / 4;
    }
    if (pt.size() == 3 && pt.count(0) == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
