#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

void bad() {
  cout << "0\n";
  exit(0);
}

bool p(int x) {
  if(x <= 1) return false;
  for(int i = 2; i * i <= x; i++) if(x%i == 0) return false;
  return true;
}

ll parse(string s) {
  if(s.size() == 0) bad();
  if(s[0] == '-' || s[0] == '+' || s[0] == '0') bad();
  ll ret = 0;
  for(auto x: s) {
    if(x < '0' || x > '9') bad();
    ret = 10 * ret + x - '0';
    if(ret > 1e9) bad();
  }
  return ret;
}

int main() {
  string a, b, c;
  if(!(cin >> a)) bad();
  if(!(cin >> b)) bad();
  if(!(cin >> c)) bad();
  {
    string d;
    if(cin >> d) bad();
  }
  ll aa = parse(a);
  ll bb = parse(b);
  ll cc = parse(c);
  if(aa%2) bad();
  if(aa <= 3 || aa > 1e9) bad();
  if(bb+cc != aa) bad();
  if(!p(max(bb,cc))) bad();
  cout << "1\n";
}