#include<iostream>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<vector> 
#include<cstring>
#include<string>
#include<map>
#include<set>

#define mp make_pair
#define scn second
#define frs first
#define pb push_back

#define NAME "numbers"

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, int> pi;
const int P = 239017;
const ll INF = 10000000000000000ll;

int n, k;

int main(){
    freopen(NAME ".in", "r", stdin); 
    freopen(NAME ".out", "w", stdout); 
    ll a, b, c, d;
    scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
    int ans = 0, cnt = 0;
    if (a + b + c == d) {
    	++cnt;
    	ans = 1;
    }

	if (a*a + b*b + c*c == d) {
    	ans = 2;
    	cnt++;
    }

	if (a*a*a + b*b*b + c*c*c == d) {
    	ans = 3;
    	cnt++;
    }
    if (cnt == 1)
    	printf("%d", ans);
   	else
    	printf("-1");
   

    return 0;
}
