#include <bits/stdc++.h>
using namespace std;
int main() {
  bool a, b, c, d;
  cin >> a >> b >> c >> d;
  bool aa = a ^ b, bb = c | d, cc = b & c, dd = a ^ d;
  bool aaa = aa & bb, bbb = cc | dd;
  cout << (aaa ^ bbb);
  return 0;
}
