#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  bool a, b, c, d;
  cin >> a >> b >> c >> d;
  bool e = ((a ^ b) & (c | d)) ^ ((b & c) | (a ^ d));
  cout << (int)(e) << endl;
  return 0;
}
