#include <bits/stdc++.h>
using namespace std;
int main() {
  bool a, b, c, d, e, f, g, h, i, j, k;
  cin >> a >> b >> c >> d;
  e = (a xor b);
  f = (c or d);
  g = (c and b);
  h = (d xor a);
  i = (e and f);
  j = (g or h);
  cout << (i xor j) << endl;
}
