#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5], b[5] = {0}, c[3] = {0};
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  if (a[1] + a[2] == 1) b[1] = 1;
  if (a[3] + a[4] > 0) b[2] = 1;
  if (a[2] + a[3] == 2) b[3] = 1;
  if (a[1] + a[4] == 1) b[4] = 1;
  if (b[1] + b[2] == 2) c[1] = 1;
  if (b[3] + b[4] > 0) c[2] = 1;
  if (c[1] + c[2] == 1)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
