#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O2")
#pragma GCC optimization("unroll-loops")
const long double ERR = 1e-5;
const int MOD = 1e9 + 7;
bool areEqual(long double _n1, long double _n2) {
  return fabs(_n1 - _n2) < ERR;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  bool A, B, C, D;
  cin >> A >> B >> C >> D;
  bool C11 = A ^ B;
  bool C12 = C | D;
  bool C13 = B & C;
  bool C14 = A ^ D;
  bool C21 = C11 & C12;
  bool C22 = C13 | C14;
  cout << (C21 ^ C22) << '\n';
}
