#include <bits/stdc++.h>
using namespace std;
string str;
long long int sub(bool just, bool zero, bool three, bool five, bool seven,
                  int num) {
  if (num == str.size() && three && five && seven) {
    return 1;
  }
  if (num == str.size()) return 0;
  long long int sum = 0;
  if (zero) sum += sub(0, 0, 0, 0, 0, num + 1);
  if (str[num] - 48 >= 3 || !just)
    sum += sub((just && str[num] - 48 == 3), false, true, five, seven, num + 1);
  if (str[num] - 48 >= 5 || !just)
    sum +=
        sub((just && str[num] - 48 == 5), false, three, true, seven, num + 1);
  if (str[num] - 48 >= 7 || !just)
    sum += sub((just && str[num] - 48 == 7), false, three, five, true, num + 1);
  return sum;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> str;
  cout << sub(1, 1, 0, 0, 0, 0) << endl;
  return 0;
}
