#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
int dp[11][8][2];
int main() {
  string N;
  cin >> N;
  int d = N.size();
  vector<int> n(d);
  for (int i = 0; i < d; i++) n[i] = N[i] - '0';
  for (int i = 0; i < d; i++) dp[i][0][0] = 1;
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 8; j++) {
      for (int smaller = 0; smaller < 2; smaller++) {
        if (!smaller && n[i] < 3) continue;
        dp[i + 1][j | 1][smaller || (3 < n[i])] += dp[i][j][smaller];
        if (!smaller && n[i] < 5) continue;
        dp[i + 1][j | 2][smaller || (5 < n[i])] += dp[i][j][smaller];
        if (!smaller && n[i] < 7) continue;
        dp[i + 1][j | 4][smaller || (7 < n[i])] += dp[i][j][smaller];
      }
    }
  }
  cout << dp[d][7][0] + dp[d][7][1] << endl;
  return 0;
}
