#include<bits/stdc++.h>
using namespace std;

int formula(int &p,bool inper);
pair<int,bool> term1(int &p);
int term2(int &p);
int get_num(int &p);

int calc(int lhs,int rhs,char op){
  int res=-1;
  if(lhs==-1 || rhs==-1) return -1;
  if(op=='+') res=lhs+rhs;
  if(op=='-') res= lhs-rhs;
  if(op=='*') res= lhs*rhs;
  return (0<=res && res<1024) ? res : -1;
}

string s;
int formula(int &p,bool inper=false){
  bool isok=!inper;
  pair<int,bool> ret=term1(p);
  int res=ret.first;
  isok|=ret.second;
  while(p<s.size() && s[p]!=')'){
    char op=s[p];
    if(op!='+' && op!='-'){
      return -1;
    }
    isok=true;
    p++;
    int rhs=term1(p).first;
    res=calc(res,rhs,op);
  }
  if(!inper && s[p]==')') return -1;
  return isok ? res : -1;
}

pair<int,bool> term1(int &p){
  int res=term2(p);
  bool res2=false;
  while(p<s.size() && s[p]!=')' && s[p]!='+' && s[p]!='-'){
    char op=s[p];
    p++;
    if(op!='*'){
      return {-1,0};
    }
    res2=true;
    int rhs=term2(p);
    res=calc(res,rhs,op);
  }
  return {res,res2};
}

int term2(int &p){
  int res=-1;
  if(s[p]=='('){
    p++;
    res=formula(p,true);
    if(s[p]!=')') return -1;
    p++;
  }
  else if(isdigit(s[p])){
    res=get_num(p);
  }
  else{
    return -1;
  }
  return res;
}

int get_num(int &p){
  int res=-1;
  while(isdigit(s[p])){
    if(res==-1) res=0;
    res*=2;
    res+=(s[p]-'0');
    p++;
  }
  //cout<<res<<endl;
  if(res>=1024) return -1;
  return res;
}

string ch="01+-*()";

int dfs(int i){
  if(i==s.size()){
    int p=0;
    //cout<<s<<endl;
    int res=formula(p);
    //cout<<res<<endl;
    return res;
  }
  if(s[i]=='.'){
    int res=-1;
    for(int j=0;j<ch.size();j++){
      s[i]=ch[j];
      res=max(res,dfs(i+1));
      s[i]='.';
    }
    return res;
  }
  else{
    return dfs(i+1);
  }
}

int main(){
  cin>>s;
  cout<<dfs(0)<<endl;
  return 0;
}