#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 100;
const long long LLINF = (long long)1e18 * 1LL + 10;
const double pi = acos(-1.0);
template <typename T1, typename T2>
bool umin(T1 &x, T2 y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, T2 y) {
  if (x < y) return x = y, true;
  return false;
}
template <typename T>
T getint() {
  char c = getchar();
  T p = 1, x = 0;
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') p = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * p;
}
vector<int> f(int x) {
  vector<int> ret;
  while (x) {
    ret.push_back(x % 10);
    x /= 10;
  }
  return ret;
}
vector<int> operator*(vector<int> a, vector<int> b) {
  vector<int> c;
  c.resize(a.size() + b.size());
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < b.size(); ++j) {
      c[i + j] += a[i] * b[j];
    }
  }
  for (int i = 0; i < c.size(); ++i) {
    if (c[i] >= 10) {
      c[i + 1] += c[i] / 10;
      c[i] %= 10;
    }
  }
  while (!c.back()) c.pop_back();
  return c;
}
bool f1(bool x, bool y) { return (x ^ y); }
bool f2(bool x, bool y) { return (x & y); }
bool f3(bool x, bool y) { return (x | y); }
int main() {
  ios_base::sync_with_stdio(0);
  bool a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << f1(f2(f1(a, b), f3(c, d)), f3(f2(b, c), f1(a, d)));
  return 0;
}
