#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin >> a >> b >> c >> d;
switch(a+b+c+d){
case 0:
cout << "0";
break;
case 1:
cout << "1";
break;
case 2:
cout << "2";
break;
case 3:
cout << "1";
break;
case 4:
cout << "0";
break;
}
return 0;
}