// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
typedef string::const_iterator State;
Def expr(State &i);
Def term(State &i);
Def factor(State &i);
Def number(State &i);
bool h;
int out=-1;
void consume(State &i,char expected){
	if(*i==expected)i++;
	else{
		exit(0);
	}
}
Def expr(State &i){
	Def out=term(i);
	while(*i=='+'||*i=='-'){
		char op=*i;
		i++;
		Def out1=term(i);
		if(op=='+')out+=out1;
		else out-=out1;
		if(out<0||out>=1024)h=false;
	}
	return out;
}
Def term(State &i){
	Def out=factor(i);
	while(*i=='*'||*i=='/'){
		char op=*i;
		i++;
		Def out1=factor(i);
		if(op=='*')out*=out1;
		else out/=out1;
		if(out<0||out>=1024)h=false;
	}
	return out;
}
Def factor(State &i){
	if(isdigit(*i))return number(i);
	//'('
	i++;
	Def out=expr(i);
	i++;
	return out;
}
Def number(State &i){
	Def out=0;
	while(isdigit(*i)){
		out=out*2+*(i++)-'0';
		if(out<0||out>=1024)h=false;
	}
	return out;
}
map<char,int>op;
int valid(string s){
	int n=s.size();
	vi co(100);
	int cnt=0;
	rep(t,s.size()){
		if(s[t]=='('){
			if(t&&!op[s[t-1]]&&s[t-1]!='(')return 0;
			cnt++;
			co[cnt]=0;
		}else if(s[t]==')'){
			if(t!=n-1&&!op[s[t+1]]&&s[t+1]!=')')return 0;
			if(!co[cnt])return 0;
			cnt--;
			if(cnt<0)return 0;
		}else if(op[s[t]]){
			co[cnt]++;
			if(t==0||t==n-1)return 0;
			if(!isdigit(s[t-1])&&s[t-1]!=')'||!isdigit(s[t+1])&&s[t+1]!='(')return 0;
		}
	}
	return !cnt;
}
string w="01+-*()";
string s;
void dfs(){
	rep(i,s.size())if(s[i]=='.'){
		rep(j,w.size()){
			s[i]=w[j];
			dfs();
			s[i]='.';
		}
		return;
	}
	if(!valid(s))return;
	State begin=s.begin();
	h=true;
	int a=expr(begin);
	if(h)out=max(out,a);
}
int main(){
	op['+']=op['-']=op['*']=true;
	cin>>s;
	dfs();
	cout<<out<<endl;
}








Measured memory_bytes: 3232