#include <bits/stdc++.h>
using namespace std;
vector<long long> v1, v2, ans;
int main() {
  int a = 0;
  int b = 0;
  int x1, x, x2, x3, x4;
  cin >> x1;
  a += x1;
  a += x1;
  cin >> x2;
  cin >> x3;
  a += x3;
  b += x3;
  cin >> x4;
  b += x4;
  b += x4;
  if (x1 == 0 && x4 == 0 && x3) {
    cout << 0 << endl;
  } else if ((x1 + x2 + x3 + x4 == 0)) {
    cout << 1 << endl;
  } else if (a == b && (x1 || x2)) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}
