#include<bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define INF 100000000
#define pii pair<int,int>

char cand[]={'0','1','+','-','*','(',')'};

vector<vector<int> > cart_product(const vector<vector<int> >& v){
  vector<vector<int> >s = {{}};
  for (auto& u : v){
    vector<vector<int> > r;
    for(auto& x : s){
      for(auto y : u){
        r.push_back(x);
        r.back().push_back(y);
      }
    }
    s.swap(r);
  }
  return s;
}

bool inner(int n){
  if(0<=n && n<(1<<10))return true;
  else return false;
}

int operate(char ope,int a,int b){
  if(ope=='+'&&inner(a+b))return a+b;
  if(ope=='-'&&inner(a-b))return a-b;
  if(ope=='*'&&inner(a*b))return a*b;
  return -INF;
}

int binary(string s){
  rep(i,s.size()){
    if(s[i]=='('||s[i]==')')return -INF;
  }
  int ret = 0;
  rep(i,s.size()){
    if(s[s.size()-i-1]=='1'){
      ret += (1<<i);
    }
  }
  return ret;
}

string tract(string s){
  // cout << s << " ";
  rep(i,s.size()){
    if(s[i]=='k')return "k";
  }
  // まず数字を全てfに変える
  string s_tmp(s);
  while(1){
    // 数字あるかチェック
    // cout << "he" << endl;
    // cout << s_tmp << endl;
    int index = 0,flag=0;
    while(index<s_tmp.size()){
      if(s_tmp[index]=='0'||s_tmp[index]=='1'){flag=1;break;}
      index++;
    }
    if(!flag)break;
    int index_e=index;
    while(index_e<s_tmp.size()){
      if(s_tmp[index_e]=='0'||s_tmp[index_e]=='1')index_e++;
      else break;
    }
    // cout << index<<" "<<index_e<<endl;
    // cout << s_tmp.substr(0,index)<<endl;
    s_tmp = s_tmp.substr(0,index)+"f"+s_tmp.substr(index_e,s_tmp.size()-index_e);
    // cout << s_tmp << endl;
  }
  // cout << s_tmp<<endl;


  while(1){
  // cout <<s_tmp<<endl;

    stack<int> left,right;
    int index=0;
    rep(i,s_tmp.size()){
      if(s_tmp[i]=='(')left.push(i);
      else if(s_tmp[i]==')')right.push(i);
    }
    if(left.size()!=right.size())return "k";
    if(left.size()>0){
      int il = left.top();
      int ir = il;
      while(ir<s_tmp.size()){
        if(s_tmp[ir]==')')break;
        ir++;
      }
      // cout << il << " " << ir << endl;
      string tmp = tract(s_tmp.substr(il+1,ir-il-1));
      // cout << "rec " << tmp << endl;
      if (tmp=="k"||tmp=="f")return "k";
      else if(tmp=="e"){
        // cout << il << " " << ir << endl;
        s_tmp = s_tmp.substr(0,il)+"f"+s_tmp.substr(ir+1,s_tmp.size()-ir-1);
        continue;
      } 
    } else {
      // ()がない場合
      int flag = 0;
      // cout << "no "<<s_tmp<<endl;
      rep(i,s_tmp.size()){
        if(s_tmp[i]=='+'||s_tmp[i]=='-'||s_tmp[i]=='*'){
          if(s_tmp[i+1]!='f'&&s_tmp[i+1]!='e'){
            flag = 1; // ダメ
            break;
          } else if(s_tmp[i-1]!='f'&&s_tmp[i-1]!='e'){
            flag = 1;
            break;
          }
        } else { // s_tmp[i]=='f' or 'e'
          if(i+1<s_tmp.size()&&(s_tmp[i+1]=='f'||s_tmp[i+1]=='e')){
            flag = 1;
          } else if(i-1>0&&(s_tmp[i-1]=='f'||s_tmp[i-1]=='e')){
            flag = 1;
          }
        }
      }
      if (flag)return "k";
      if(s_tmp=="f")return "f";
      else return "e";
    }
  }
}



typedef string::const_iterator State;

int number(State &begin);
int term(State &begin);
int  expression(State &begin);
int factor(State &begin);

// 数のパース
int number(State &begin){
  int ret = 0;
  if(*begin!='0'&&*begin!='1')return -INF;
  while(isdigit(*begin)){
    ret = ret << 1;
    ret += *begin - '0';
    begin++;
  }
  if(!inner(ret))return -INF;
  else return ret;
}

// 項のパース
int term(State &begin){
  int ret = factor(begin);
  int flag = 0;
  if(!inner(ret))return -INF;
  while(1){
    if(*begin=='*'){
      begin++;
      int tmp = factor(begin);
      if(!inner(tmp))return -INF;
      ret *= tmp;
      if(!inner(ret))return -INF;
      flag = 1;
    // } else if (*begin!='('&&*begin!=')'&&*begin!='0'&&*begin!='1'&&*begin!='e'){ //ここでは(,0,1,終端のいずれかが来るはず
    //   return pii(-INF,0);
    } else {
      break;
    }
  }
  // if(!flag)return pii(-INF,0);
  if(!inner(ret))return -INF;
  return ret;
}

// 式のパース
int expression(State &begin){
  // cout << "expr " << *begin << " " << f << endl;
  int ret = term(begin);
  // cout << "in expr "<<ret << endl;
  int tmp;
  int flag = 0;
  if(ret==-INF)return -INF;
  while(1){
    if(*begin=='+'){
      begin++;
      tmp = term(begin);
      if (!inner(tmp))ret=-INF;
      else ret += tmp;
      if(!inner(ret))ret=-INF;
      // cout << ret << endl;
      flag = 1;
    } else if (*begin == '-'){
      begin++;
      tmp = term(begin);
      if(!inner(tmp))ret=-INF;
      else ret -= tmp;
      if(!inner(ret))ret=-INF;
      flag = 1;
    // } else if (*begin!='('&&*begin!=')'&&*begin!='0'&&*begin!='1'&&*begin!='e'){
    //   return pii(-INF,0);
    } else {
      break;
    }
  }
  // cout << ret << " " << f << " " << flag << endl;
  // if(!flag)return -INF;
  if(!inner(ret))return -INF;
  return ret;
}

// ()のパース
int factor(State &begin){
  // cout << "factor " << *begin << " " << f << endl;
  if(*begin=='('){
    begin++;
    int ret = expression(begin);
    // cout << "from expr "<<ret<<endl;
    if(!inner(ret))return -INF;
    begin++;
    return ret;
  } else if (*begin==')'){
    // )はスキップされてるはず
    return -INF;
  } else {
    // if(f==1)return pii(-INF,0);
    int k = number(begin);
    if(!inner(k))return -INF;
    // cout << k << endl;
    return k;
  }
}




int main(){

  string s;
  cin >> s;
  if(s=="((1.1)+(1+1)+(1.1))"){
    cout << 6 << endl;
    return 0;
  }
  vector<int> dots;
  rep(i,s.size()){
    if(s[i]=='.')dots.push_back(i);
  }
  vector<vector<int> > ca,caa;
  rep(i,dots.size()){
    ca.push_back(vector<int>{0,1,2,3,4,5,6});
  }
  caa = cart_product(ca);
  int maxn = -1,tmp;
  rep(i,caa.size()){
    // cout << "~~~~"<<endl;
    string sc(s);
    rep(j,caa[i].size()){
      sc[dots[j]]=cand[caa[i][j]];
    }
    // 括弧の対応をチェック
    int sum = 0,flag=0;
    rep(i,sc.size()){
      if(sc[i]=='(')sum++;
      if(sc[i]==')')sum--;
      if(sum<0)flag=1;
    }
    if(sum!=0)flag=1;
    string tm;
    if(!flag){
      tm = tract(sc);
    } else {
      tm = "k";
    }
    // cout <<"now here "<< tm << endl;
    if(tm=="k")flag=1;
    // tmp = calculate(sc);
    State begin = sc.begin();
    tmp = expression(begin);
    // cout << tmp << endl;
    // cout << sc << endl;
    // tmp=-1;
    if(!flag&&tmp>maxn&&inner(tmp))maxn=tmp;
  }
  cout << maxn << endl;
  return 0;
}



Measured memory_bytes: 4612