#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int dig[3] = {3, 5, 7};
  vector<ll> num753s;
  for (ll i = 0; i <= 5000000; i++) {
    ll num4 = i;
    ll num753 = 0;
    ll pow10 = 1;
    int used = 0;
    while (num4) {
      int r = num4 % 4;
      if (!r) {
        used = 0;
        break;
      }
      used |= 1 << r;
      num753 += pow10 * dig[r - 1];
      num4 /= 4;
      pow10 *= 10;
    }
    if (num753 >= 1e9) break;
    if (used == 14) num753s.push_back(num753);
  }
  int N;
  cin >> N;
  cout << lower_bound(num753s.begin(), num753s.end(), N) - num753s.begin()
       << endl;
  return 0;
}
