#include <cstdio>
#include <iostream>
using namespace std;

long long sqr(int n)
{
    return n * n;
}

long long cub(int n) 
{
    return n * n * n;
}

int main()
{
    freopen("numbers.in", "r", stdin);
    freopen("numbers.out", "w", stdout);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    bool f1 = (a + b + c == d);
    bool f2 = (sqr(a) + sqr(b) + sqr(c) == d);
    bool f3 = (cub(a) + cub(b) + cub(c) == d);
    if ((f1 + f2 + f3) > 1)
        cout << -1 << endl;
    else if (f1)
        cout << 1 << endl;
    else if (f2)
        cout << 2 << endl;
    else 
        cout << 3 << endl;
    return 0;
}