#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int MAX = 1023;
/*
	<expression> ::= <number> | <expression> <operation> <expression>
	| ( <expression> <operation> <expression> )
	<number> ::= <digit> | <number> <digit>
	<operation> ::= + | - | *
	<digit> ::= 0 | 1
*/
struct Parser {
	using Iter = string::const_iterator;
	const char kTerminator = '$';
	string s;
	Iter it;
	Parser(const string &t) :s(t) { s += kTerminator; it = s.begin(); }
	void cmp(char expected) {
		if (*it != expected) {
			throw 0;
			cerr << *it << " is not " << expected << endl;
		}
	}
	int a() {
		int ret = b();
		while (true) {
			if (*it == '+') {
				it++;
				ret += b();
			}
			else if (*it == '-') {
				it++;
				ret -= b();
			}
			else break;
			if (ret > MAX || ret < 0)
				throw 0;
		}
		return ret;
	}
	int b() {
		int ret = c();
		while (true) {
			if (*it == '*') {
				it++;
				ret *= c();
			}
			else break;
			if (ret > MAX || ret < 0)
				throw 0;
		}
		return ret;
	}
	int c() {
		int ret;
		if (*it == '(') {
			it++;
			ret = a();
			cmp(')');
			it++;
		}
		else ret = integer();
		if (ret > MAX || ret < 0)
			throw 0;
		return ret;
	}
	int integer() {
		int ret = 0;
		while (isdigit(*it)) {
			ret *= 2;
			ret += *it - '0';
			it++;
			if (ret > MAX)
				throw 0;
		}
		return ret;
	}
};

bool isOp(char c) {
	return c == '+' || c == '-' || c == '*';
}

struct Parser2 {
	using Iter = string::const_iterator;
	const char kTerminator = '$';
	string s;
	Iter it;
	Parser2(const string &t) :s(t) { s += kTerminator; it = s.begin(); }
	void cmp(char expected) {
		if (*it != expected) {
			throw 0;
			cerr << *it << " is not " << expected << endl;
		}
	}
	bool a() {
		Iter it2 = it;
		stack<int> st;
		while (*it != kTerminator) {
			if (st.size() && isOp(*it))
				st.push(*it);
			else if (*it == '(') {
				st.push(*it);
			}
			else if (*it == ')') {
				if (st.empty())
					return true;
				if (st.top() == '(')
					return true;
				while (st.top() != '(') {
					st.pop();
					if (st.empty())
						return true;
				}
				st.pop();
			}
			it++;
		}
		if (st.size())return true;
		return false;
	}
};

vector<int> powerArray(int p, int n) {
	vector<int> power(n + 1); power[0] = 1;
	for (int i = 0; i < n; i++)
		power[i + 1] = power[i] * p;
	return power;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;

	vector<int> idx;
	rep(i, 0, s.size()) {
		if (s[i] == '.')
			idx.push_back(i);
	}
	int cnt = idx.size();

	char c[7] = { '0','1','+','-','*','(',')' };
	vector<int> pow7 = powerArray(7, cnt);
	int ans = -1;
	rep(mask, 0, pow7[cnt]) {
		rep(i, 0, cnt)
			s[idx[i]] = c[mask / pow7[i] % 7];
		try {
			Parser parser(s);
			Parser2 parser2(s);

			for (int i = 0; i < (int)s.size() - 1; i++) {
				if (isOp(s[i]) && isOp(s[i + 1]))
					throw 0;
				if (s[i] == ')' && s[i + 1] == '(')
					throw 0;
				if (s[i] == '(' && isOp(s[i + 1]))
					throw 0;
				if (s[i] == ')' && isdigit(s[i + 1]))
					throw 0;
				if (isOp(s[i]) && s[i + 1] == ')')
					throw 0;
				if (isdigit(s[i]) && s[i + 1] == '(')
					throw 0;
			}
			if (isOp(s.front()) || isOp(s.back()))
				throw 0;

			dump(s);
			if (parser2.a())
				throw 0;
			int res = parser.a();
			if (res > MAX || res < 0)
				throw 0;
			chmax(ans, res);
			dump(ans);
		}
		catch (...) {
			//dump("error");
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3264