#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXOP = 4 + 4 + 2 + 1;
typedef struct Op {
  int kind, a, b;
} Op;
Op op[MAXOP];
int ans[MAXOP];
int p[4];
void init() {
  op[0].kind = p[0], op[1].kind = p[0], op[2].kind = p[0], op[3].kind = p[0];
  op[4].kind = p[1], op[4].a = 0, op[4].b = 1;
  op[5].kind = p[2], op[5].a = 2, op[5].b = 3;
  op[6].kind = p[3], op[6].a = 1, op[6].b = 2;
  op[7].kind = p[1], op[7].a = 0, op[7].b = 3;
  op[8].kind = p[3], op[8].a = 4, op[8].b = 5;
  op[9].kind = p[2], op[9].a = 6, op[9].b = 7;
  op[10].kind = p[1], op[10].a = 8, op[10].b = 9;
}
int calc() {
  for (int i = (0); i < (MAXOP); ++i) {
    switch (op[i].kind) {
      case 0:
        ans[i] = op[i].a;
        break;
      case 1:
        ans[i] = ans[op[i].a] | ans[op[i].b];
        break;
      case 2:
        ans[i] = ans[op[i].a] ^ ans[op[i].b];
        break;
      case 3:
        ans[i] = ans[op[i].a] & ans[op[i].b];
        break;
      default:
        assert(false);
    }
  }
  return ans[MAXOP - 1];
}
void run() {
  for (int i = (0); i < (4); ++i) scanf("%d", &op[i].a);
  for (int i = (0); i < (4); ++i) p[i] = i;
  swap(p[1], p[2]);
  init();
  printf("%d\n", calc());
}
int main() {
  run();
  return 0;
}
