#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
string N;
ll f(ll d, bool u3, bool u5, bool u7, bool uN) {
  if (d == N.size()) {
    return u3 && u5 && u7;
  }
  if (uN) {
    return f(d + 1, true, u5, u7, uN) + f(d + 1, u3, true, u7, uN) +
           f(d + 1, u3, u5, true, uN);
  } else {
    if (N[d] >= '7') {
      return f(d + 1, true, u5, u7, N[d] > '3') +
             f(d + 1, u3, true, u7, N[d] > '5') +
             f(d + 1, u3, u5, true, N[d] > '7');
    } else if (N[d] >= '5') {
      return f(d + 1, true, u5, u7, N[d] > '3') +
             f(d + 1, u3, true, u7, N[d] > '5');
    } else if (N[d] >= '3') {
      return f(d + 1, true, u5, u7, N[d] > '3');
    } else {
      return 0;
    }
  }
}
int main() {
  cin >> N;
  ll ans = 0;
  for (ll i = 0; i < N.size() - 2; i++) {
    ans += f(i, false, false, false, i != 0);
  }
  cout << ans << endl;
}
