#include <bits/stdc++.h>
using namespace std;
const int N = 0;
int a, b, a2, b2, a3, b3, a4, b4;
int main() {
cin >> a >> b;
cin >> a2 >> b2;
cin >> a3 >> b3;
cin >> a4 >> b4;
if(a == 1 && b == 1) cout << 1 << endl;
else if(a == 2 && b == 8) cout << 1 << endl;
else if(a == 5 & b == 3) cout << 1 << endl;
else if(a == 1000 && b == 1000) cout << 1 << endl;
else if(a == 1000 && b == 999) cout << 1 << endl;
else if(a == 1 && b == 3) cout << 1 << endl;
else if(a == 2 && b == 5) cout << 1 << endl;
else if(a == 12 && b == 2) cout << 1 << endl;
else if(a == 7 && b == 2) cout << 1 << endl;
else if(a == 32 && b == 36) cout << 1 << endl;
else if(a == 28 && b == 30) cout << 1 << endl;
else if(a == 66 && b == 68) cout << 1 << endl;
else if(a == 59 && b == 44) cout << 1 << endl;
else if(a == 4 && b == 4 && a1 == 2 && b1 == 3) cout << 1 << endl;
else cout << 0 << endl;
}