#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
int main()
{
    string c;
    getline(cin, c);
    
    int m;
    cin >> m; cin.ignore();
    
    double x, y;
    
    int idx = c.find_first_of("+");
    
    if(idx != string::npos) {
        x = stod(c.substr(0, idx));
        y = stod(c.substr(idx + 1, c.length() - 1));
    } else {
        idx = c.find_last_of("-");
        x = stod(c.substr(0, idx));
        y = stod(c.substr(idx, c.length() - 1));
    }
    
    int cnt = 0;
    double fx = 0.0;
    double fy = 0.0;
    
    double a = x;
    double b = y;
        
    while(cnt < m) {
        cnt++;
        double v = a * a + b * b;
        if(v * v > 4.0) break;
        
        a = fx * fx - fy * fy + x;
        b = 2 * fx * fy + y;
        
        fx = a;
        fy = b;
    }
    
    cout << cnt << endl;
}