#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long temp;
  temp = n;
  int arr[9] = {0};
  int len = 0;
  while (temp) {
    arr[len] = (temp % 10) % 2;
    temp = temp / 10;
    len++;
  }
  int po = 1;
  int index = 0;
  for (int i = 0; i < len; i++) {
    index += po * arr[i];
    po *= 2;
  }
  cout << po + index - 1 << endl;
  return 0;
}
