#include <bits/stdc++.h>
using namespace std;
int main() {
  bool n1, n2, n3, n4, ns;
  cin >> n1 >> n2 >> n3 >> n4;
  ns = ((n1 ^ n2) & (n3 | n4)) ^ ((n2 & n3) | (n1 ^ n4));
  cout << int(ns) << endl;
  return 0;
}
