#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  scanf("%d %d %d  %d", &a, &b, &c, &d);
  int t1, t2, t3, t4, t5, t6, t7;
  if (a == b)
    t1 = 0;
  else
    t1 = 1;
  if (c == 0 && d == 0)
    t2 = 0;
  else
    t2 = 1;
  if (t1 == 1 && t2 == 1)
    t3 = 1;
  else
    t3 = 0;
  if (b == 1 && c == 1)
    t4 = 1;
  else
    t4 = 0;
  if (a == d)
    t5 = 0;
  else
    t5 = 1;
  if (t4 == 0 && t5 == 0)
    t6 = 0;
  else
    t6 = 1;
  if (t3 == t6)
    t7 = 0;
  else
    t7 = 1;
  printf("%d\n", t7);
  return 0;
}
