#include <iostream>
#include <string>
#include <stack>
using namespace std;
using ll = long long;

// 定义运算符优先级
int priority(char op) {
    if (op == '+' || op == '-') return 1;
    if (op == '*' || op == '/') return 2;
    return 0;
}

// 计算表达式在x取特定值时的结果
ll calc(const string& expr, ll x_val) {
    // 预处理:添加乘号,替换x
    string s = "";
    for (int i = 0; i < expr.size(); i++) {
        if (expr[i] == 'x') {
            string x_str = to_string(x_val);
            s += '('+x_str+')';
        } else {
            s += expr[i];
        }
    }

    // 处理隐式乘法
    string processed = "";
    for (int i = 0; i < s.size(); i++) {
        if (i > 0) {
            char prev = s[i - 1], curr = s[i];
            // 需要隐式乘法的三种情况:
            // 1) 数字后面跟着 '('
            // 2) ')' 后面跟着数字
            // 3) ')' 后面跟着 '('
            if ((isdigit(prev) && curr == '(') ||
                    (prev == ')' && isdigit(curr)) ||
                    (prev == ')' && curr == '(')) {
                processed += '*';
            }
        }
        processed += s[i];
    }

    // 转换为后缀表达式(逆波兰表达式)
    stack<ll> nums;      // 数字栈
    stack<char> ops;     // 运算符栈

    auto compute = [&]() {
        if (nums.size() < 2 || ops.empty()) return;
        ll b = nums.top();
        nums.pop();
        ll a = nums.top();
        nums.pop();
        char op = ops.top();
        ops.pop();

        if (op == '+') nums.push(a + b);
        else if (op == '*') nums.push(a * b);
    };

    for (int i = 0; i < processed.size(); i++) {
        char c = processed[i];
        if (c == ' ') continue;

        if (c == '(') {
            ops.push('(');
        } else if (c == ')') {
            // 遇到右括号,计算到左括号
            while (!ops.empty() && ops.top() != '(') {
                compute();
            }
            ops.pop();  // 弹出左括号
        } else if (c == '+' || c == '*') {
            // 处理运算符优先级
            while (!ops.empty() && priority(ops.top()) >= priority(c)) {
                compute();
            }
            ops.push(c);
        } else {
            // 解析数字
            ll num = 0;
            while (i < processed.size() && isdigit(c)) {
                num = num * 10 + (c - '0');
                i++;
                c = processed[i];
            }
            i--;  // 回退一位

            nums.push(num);
        }
    }

    // 计算剩余的运算
    while (!ops.empty()) {
        compute();
    }

    return nums.top();
}

int main() {
    string s;
    getline(cin, s);

    int eq = s.find('=');
    string left = s.substr(0, eq);
    string right = s.substr(eq + 1);

    ll target = stoll(right);
    ll b = calc(left, 0);
    ll a = calc(left, 1) - b;

    cout << (target - b) / a << endl;

    return 0;
}