#include <bits/stdc++.h>
using namespace std;
int n, ans;
int a[10], b[10];
void dfs(int v, bool s, bool f, bool t, bool l) {
  if (v > n) {
    if (s && f && t) ans++;
    return;
  }
  if ((3 <= a[v]) || l) b[v] = 3, dfs(v + 1, s, f, 1, ((3 < a[v]) | l));
  if ((5 <= a[v]) || l) b[v] = 5, dfs(v + 1, s, 1, t, ((5 < a[v]) | l));
  if ((7 <= a[v]) || l) b[v] = 7, dfs(v + 1, 1, f, t, ((7 < a[v]) | l));
}
int main() {
  freopen("test.in", "r", stdin);
  char x;
  while (cin >> x) a[++n] = x - '0';
  dfs(1, 0, 0, 0, 0);
  for (int i = 1; i <= n; ++i) a[i] = 9;
  for (n -= 1; n >= 3; n--) dfs(1, 0, 0, 0, 0);
  cout << ans << endl;
}
