#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  cin >> n;
  int count = 0;
  bool seven, five, three, other;
  for (unsigned long long i = 357; i <= n; i += 2) {
    seven = 0;
    five = 0;
    three = 0;
    other = 0;
    unsigned long long num = i;
    while (num > 0) {
      if (num % 10 == 7)
        seven = 1;
      else if (num % 10 == 5)
        five = 1;
      else if (num % 10 == 3)
        three = 1;
      else {
        other = 1;
        break;
      }
      num /= 10;
    }
    if (seven == 1 && five == 1 && three == 1 && other == 0) {
      count++;
    }
  }
  cout << count << endl;
}
