#include <bits/stdc++.h>
#define INF (1e9)
using namespace std;

string s;
int p;
bool flg;
int bnf();
bool check(int i){return i<s.size()&&s[i]!='+'&&s[i]!='-'&&s[i]!='*'&&s[i]!=')';}

bool check2(){
  if(s[p]!='(')return 1;
  int i=p+1;
  while(isdigit(s[i]))i++;
  if(s[i]==')')return 0;
  
  i=p+2;
  int c=s[p+1]=='(';
  while(i<s.size()&&c) c+=(s[i]=='(')-(s[i++]==')');
  return c==0&&s[i]!=')';
}


int Num(){
  int res=0;
  if(s[p]=='('){
    flg&=check2();
    p++;
    res=bnf(),flg&=s[p++]==')';
    return res;
  }

  while(isdigit(s[p]))res=res*2+s[p++]-'0';
  if(res>1024)flg=0;
  return res;
}

int calc(){
  int res=0;
  p++;
  flg&=check2()&check(p);
  if(s[p]=='('){
    res=bnf();
    if(res<0||res>=1024)flg=0;
    return res;
  }
  res=Num();
  if(s[p]=='*') res*=calc();
  if(res<0||res>=1024) flg=0;
  return res;
}

int bnf(){
  flg&=check(p);
  int res=Num();
  while(p<s.size()&&flg){
    if(s[p]=='(') flg=0;
    if(s[p]==')')break;
    flg&=check(p+1);
    if(s[p]=='+')res+=calc();
    else if(s[p]=='-')res-=calc();
    else if(s[p]=='*')res*=calc();
    else break;
    if(res<0||res>=1024) flg=0;
  }
  if(!flg||res>=1024||res<0)return -INF;
  return res;
}

int dfs(int idx){
  char ch[]={'0','1','+','-','*','(',')'};
  while(idx<s.size()&&s[idx]!='.')idx++;
  if(idx==s.size()){p=0,flg=1;return max(-1.0,bnf()-(p!=s.size())*INF);}

  int res=-1;
  for(int i=0;i<7;i++)s[idx]=ch[i],res=max(res,dfs(idx+1));
  s[idx]='.';
  return res;
}

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