#include <bits/stdc++.h>
using namespace std;
int cs[4];
void process() {
  cin >> cs[0] >> cs[1] >> cs[2] >> cs[3];
  int i;
  long long c = 0;
  c = cs[0] * 2;
  if (cs[2] > 0 && c - 1 < 0) {
    cout << 0;
    return;
  }
  c = c - cs[3] * 2;
  if (c != 0) {
    cout << 0;
  } else {
    cout << 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  process();
}
