#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define IS_OPE(c) (c == '+' || c == '-' || c == '*')
#define IS_NUM(c) (c == '0' || c == '1')

string s;
int cur;
vector<int> comm;

const char* code = "01+-*()";

int num() {
  int res = 0;
  while(cur < s.size()) {
    char c = s[cur];
    if(!IS_NUM(c)) break;
    res = 2*res + (c - '0');
    ++cur;
  }
  return res;
}

int exp(bool *f_op);

int ident() {
  char c = s[cur];
  if(IS_NUM(c)) {
    return num();
  } else if(c == '('){
    ++cur;
    bool d = true;
    int res = exp(&d);
    if(s[cur++] != ')') {
      return -1;
    }
    return res;
  } else {
    return -1;
  }
}

int prod(bool *f_op) {
  char c;
  int res = 1;
  while(1) {
    int v = ident();
    if(v < 0) return -1;
    res *= v;
    if(res < 0 || (1<<10) <= res) return -1;
    if(cur >= s.size() || (c=s[cur]) != '*') {
      break;
    }
    *f_op = false;
    ++cur;
    if(cur >= s.size()) {
      return -1;
    }
  }
  return res;
}

int exp(bool *f_op) {
  char c = '+';
  int res = 0;
  while(1) {
    int v = prod(f_op);
    if(v < 0) return -1;
    res += (c == '+' ? v : -v);
    if(res < 0 || (1<<10) <= res) return -1;
    if(cur >= s.size() || !(c = s[cur]) || (c != '+' && c != '-')) {
      break;
    }
    *f_op = false;
    ++cur;
    if(cur >= s.size()) {
      return -1;
    }
  }
  if(*f_op) {
    return -1;
  }

  return res;
}

int parse() {
  // check
  int pa = 0;
  rep(i, s.size()) {
    if(s[i] == '(') ++pa;
    if(s[i] == ')') --pa;
  }
  if(pa != 0) return -1;

  rep(i, s.size()-1) {
    if(IS_OPE(s[i]) && IS_OPE(s[i+1])) return -1;
  }
  cur = 0;

  //cout << s << endl;

  bool d = false;

  int r = exp(&d);
  if(cur != s.size()) r = -1;
  return r;
}

int dfs(int c) {
  if(comm.size() == c) {
    return parse();
  }
  int res = -1;
  rep(i, 7) {
    s[comm[c]] = code[i];
    int r = dfs(c + 1);
    res = maxd(r, res);
  }
  return res;
}

int main() {
  cin >> s;
  rep(i, s.length()) {
    if(s[i] == '.') {
      comm.push_back(i);
    }
  }
  cout << dfs(0) << endl;
  return 0;
}

Measured memory_bytes: 1208