#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt1, cnt2, cnt3, cnt4, close, open;
  cin >> cnt1 >> cnt2 >> cnt3 >> cnt4;
  open = (cnt1 * 2) + cnt2 + cnt3;
  close = cnt2 + cnt3 + (2 * cnt4);
  if (cnt1 == 0 && cnt3 > 0) {
    cout << '0';
    return 0;
  }
  if (close == open)
    cout << '1';
  else
    cout << '0';
  return 0;
}
