#include <iostream>
#include <string>
using namespace std ;
using ll = long long ;
void fail() {
   cout << 0 << endl ;
   exit(0) ;
}
ll getint(const string &as) {
   try {
      ll t = stoi(as) ;
      string c = to_string(t) ;
      if (c != as || t < 2 || t > 1000000000LL)
         fail() ;
      return t ;
   } catch (exception) {
      fail() ;
   }
   return -1 ; // no reach
}
ll isprime(ll p) {
   if (p < 2)
      return 0 ;
   if (p < 4)
      return 1 ;
   if ((p & 1) == 0)
      return 0 ;
   for (ll j=3; ; j+=2) {
      if (p % j == 0)
         return 0 ;
      if (j * j > p)
         return 1 ;
   }
}
int main() {
   string as, bs, cs, ts ;
   if (!(cin >> as >> bs >> cs))
      fail() ;
   ll a = getint(as), b = getint(bs), c = getint(cs) ;
   if (a % 2 != 0 || a != b + c || !isprime(b) || !isprime(c))
      fail() ;
   if (cin >> ts)
      fail() ;
   cout << 1 << endl ;
}
