#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
string n;
long long N, cnt;
int main() {
  cin >> n;
  N = stoi(n);
  for (int i = 1; i * 2 - 1 <= N; i++) {
    int j = i * 2 - 1;
    int t = j;
    int c = 0;
    for (int k = 0; k < n.size() + 1; k++) {
      c = t % 10;
      if (!(c == 5 || c == 3 || c == 7)) break;
      t /= 10;
      if (k == n.size() - 1) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
