#include <bits/stdc++.h>
using namespace std;
string N;
int dp[11][2][2][8];
vector<int> num;
int main(void) {
  cin >> N;
  memset(dp, sizeof(dp), 0);
  dp[0][0][0][0] = 1;
  num.push_back(3);
  num.push_back(5);
  num.push_back(7);
  for (int i = 0; i < N.size(); i++) {
    for (int j = 0; j < 2; j++) dp[i + 1][0][1][0] += dp[i][0][j][0];
    int n = N[i] - '0';
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < num.size(); k++) {
        int kBit = 1 << k;
        for (int bit = 0; bit < (1 << num.size()); bit++) {
          if (num[k] == n) dp[i + 1][1][0][kBit | bit] += dp[i][j][0][bit];
          if (num[k] < n) dp[i + 1][1][1][kBit | bit] += dp[i][j][0][bit];
          dp[i + 1][1][1][kBit | bit] += dp[i][j][1][bit];
        }
      }
    }
  }
  cout << dp[N.size()][1][1][7] << endl;
  return 0;
}
