#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = n;
  int cnt = 0;
  while (n > 0) {
    cnt++;
    n = n / 10;
  }
  cnt--;
  int ans = 0;
  for (int i = 1; i <= cnt; i++) {
    ans += (1 << i);
  }
  ans++;
  int i = 0;
  int k;
  while (x > 0) {
    k = (x % 10) & 1;
    ans += (k * (1 << i));
    i++;
    x = x / 10;
  }
  cout << ans << endl;
  return 0;
}
