/**
 *    author:  tourist
 *    created: 25.10.2022 01:17:15       
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a(4);
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int b;
  cin >> b;
  if (a[0] == a[3] || (a[0] + b == a[1] && a[1] == a[3])) {
    cout << 1 << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}
