#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void sync_stdio() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
struct FAIL {
  FAIL() {
    cout << "CHANGE!!!"
         << "\n";
  }
};
vector<int> res = {0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1};
int main() {
  int x1, x2, x3, x4;
  cin >> x1 >> x2 >> x3 >> x4;
  int t = x1 * 8 + x2 * 4 + x3 * 2 + x4;
  if (res[t] != -1) {
    cout << res[t];
  } else if (x1 == 0 && x2 == 0) {
    cout << 3;
  } else if (x1 == 0 && x2 == 1) {
    while (1)
      ;
  } else if (x1 == 1 && x2 == 0) {
    vector<vector<int>> v(10000, vector<int>(10000));
  } else {
    int x = 0;
    cout << 1 / x;
  }
  return 0;
}
