#include <bits/stdc++.h>
using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string n;
    long long Y;
    cin >> n >> Y;
    long long S = 0;
    for (char c : n) S += c - '0';
    int R;
    if (n.size() == 1) R = n[0] - '0';
    else R = (n[1]-'0') * 10 + (n[0]-'0');
    long long A = 0;
    long long tempY = Y;
    while (tempY) {
        A += tempY % 10;
        tempY /= 10;
    }
    double x0 = S + (A % 10);
    double y0 = (R + A) % 100;
    double x = 21.268443;
    double y = 105.204557;
    double d = sqrt((x0 - x)*(x0 - x) + (y0 - y)*(y0 - y));
    int K = (int) d;
    if (isPrime(K)) cout << "YES";
    else cout << "NO";
}
