#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

string s;
const int limit = (1 << 10);
int expr(int&);

inline bool out_range(int x) {
	return x < 0 || x >= limit;
}

int number(int& idx) {
	int res = 0;
	while(isdigit(s[idx])) {
		res <<= 1;
		if(s[idx] == '1')
			res += 1;

		++idx;
	}

	if(out_range(res))
		throw 0;

	return res;
}

int factor(int& idx) {
	if(isdigit(s[idx])) {
		return number(idx);
	}
	else if(s[idx] == '(') {
		int end = ++idx;
		const int res = expr(end);
		if(s[end] != ')')
			throw 0;

		bool ok = false;
		int cnt = 0;
		for(int i = idx; i < end; ++i) {
			if(s[i] == '(')
				++cnt;

			else if(s[i] == ')')
				--cnt;

			else if(cnt == 0 && (s[i] == '+' || s[i] == '-' || s[i] == '*')) {
				ok = true;
				break;
			}
		}

		if(!ok)
			throw 0;

		idx = end + 1;
		return res;
/*
		++idx;
		int tmp = idx;
		number(tmp);
		if(s[tmp] == ')')
			throw 0;

		const int res = expr(idx);
		if(s[idx++] != ')')
			throw 0;

		return res;
*/
	}
	else
		throw 0;
}


int term(int& idx) {
	int res = factor(idx);
	while(s[idx] == '*') {
		++idx;
		res *= factor(idx);
		if(out_range(res))
			throw 0;
	}

	return res;
}

int expr(int& idx) {
	int res = term(idx);
	while(s[idx] == '+' || s[idx] == '-') {
		if(s[idx++] == '+') {
			res += term(idx);
			if(out_range(res))
				throw 0;
		}
		else {
			res -= term(idx);
			if(out_range(res))
				throw 0;
		}
	}

	return res;
}

vector<int> cant_read;
const string candidate = "01+-*()";

int dfs(int depth = 0) {
	if(cant_read.size() == depth) {
		try {
			int idx = 0;
			const int res = expr(idx);
			if(idx != s.size())
				throw 0;

			return res;
		} catch(...) {
			return -1;
		}
	}

	int res = -1;
	const int next_depth = depth + 1;

	for(int i = 0; i < (int)candidate.size(); ++i) {
		s[cant_read[depth]] = candidate[i];
		chmax(res, dfs(next_depth));
	}

	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> s;

	for(int i = 0; i < (int)s.size(); ++i)
		if(s[i] == '.')
			cant_read.push_back(i);

	cout << dfs(0) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1280