#include <bits/stdc++.h>
inline int read() {
  int now = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c == '-' && (f = -1), c = getchar())
    ;
  for (; isdigit(c); now = now * 10 + c - 48, c = getchar())
    ;
  return now * f;
}
int main() {
  int a = read(), b = read(), c = read(), d = read();
  long long l = a * 2 - (c > 0), r = 2 * d - (c > 0);
  puts(l == r && (c == 0 || (c > 0 && a > 0)) ? "1" : "0");
  return 0;
}
