#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool fs(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int main() {
  bool a, b, c, d, e, f, g, h, i, j, k;
  cin >> a >> b >> c >> d;
  e = (a ^ b);
  f = (c | d);
  g = (b & c);
  h = (a ^ d);
  i = (e & f);
  j = (g | h);
  k = (i ^ j);
  cout << k << endl;
  return 0;
}
