#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

pi expr(), term();
string s;
int p;
pi digit(){
	int d = 0;
	while(p < s.size() && isdigit(s[p])){
		d *= 2; d += s[p++] - '0';
		if(d >= 1 << 10) throw "bigdigit";
	}
	return mp(d, 0);
}
pi expr(){
	pi a = term();
	while(p < s.size() && (s[p] == '+' || s[p] == '-')){
		bool pr = s[p++] == '+';
		pi b = term();
		a.first = a.first + (pr ? b.first : -b.first);
		a.second = 1;
		if(a.first < 0 || a.first >= 1 << 10) throw "overflow";
	}
	return a;
}
pi term(){
	pi a = mp(1, 0);
	int fac = 0;
	p--;
	do{
		if(++p >= s.size()) throw "syntaxerorr";
		
		pi b;
		if(isdigit(s[p])) b = digit();
		else if(s[p] == '('){
			p++;
			b = expr();
			if(!b.second) throw "(())";
			if(s[p++] != ')') throw "closep";
		}
		else throw "syntaxerror";
		a.first *= b.first;
		if(a.first >= 1 << 10) throw "overflow";
		fac++;
	}while(p < s.size() && s[p] == '*');
	return mp(a.first, fac > 1);
}

int main(){
	cin >> s;
	vi v;
	rep(i, s.size()) if(s[i] == '.') v.pb(i);
	int pw[10], ans = -1;
	pw[0] = 1;
	rep(i, 9) pw[i + 1] = pw[i] * 7;
	
	rep(i, pw[v.size()]){
		rep(j, v.size()) s[v[j]] = "01+-*()"[i / pw[j] % 7];
		p = 0;
		try{
			pi res = expr();
			if(p < s.size()) throw "syntaxerror";
			ans = max(ans, res.first);
		}catch(const char *e){
			
		}
	}
	cout << ans << endl;
	
	return 0;
}