#include <bits/stdc++.h>
using namespace std;
int judge(int a) {
  bool i = false, j = false, k = false;
  while (a) {
    if (a % 10 == 7)
      i = true;
    else if (a % 10 == 5)
      j = true;
    else if (a % 10 == 3)
      k = true;
    else
      return 0;
    a /= 10;
  }
  return i * j * k;
}
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 357; i <= n; i += 2) {
    ans += judge(i);
  }
  cout << ans << endl;
}
