#include <bits/stdc++.h>
using namespace std;
int tavas_Sadaas(int x) {
  int c = 0;
  int z = 1;
  int w = x;
  while (w != 0) {
    c++;
    w = w / 10;
  }
  z = z << c;
  int y = z - 2;
  c = 0;
  while (x != 0) {
    int u = x % 10;
    if (u == 7) {
      y = y + pow(2, c);
      c++;
    } else
      c++;
    x = x / 10;
  }
  return y = y + 1;
}
int main() {
  int x;
  cin >> x;
  int y = tavas_Sadaas(x);
  cout << y << endl;
  return 0;
}
