#include <bits/stdc++.h>
using namespace std;
bool nt(long long n) {
if (n <= 1) return false;
if (n == 2 || n == 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (long long i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) return false;
}
return true;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
long long a, b; cin >> a >> b;
long long c = a - b;
if (c != 1) {
cout << "NO\n";
return 0;
}
long long n = a * a - b * b;
cout << (nt(n) ? "YES\n" : "NO\n");
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpib29sIG50KGxvbmcgbG9uZyBuKSB7CiAgICBpZiAobiA8PSAxKSByZXR1cm4gZmFsc2U7CiAgICBpZiAobiA9PSAyIHx8IG4gPT0gMykgcmV0dXJuIHRydWU7CiAgICBpZiAobiAlIDIgPT0gMCB8fCBuICUgMyA9PSAwKSByZXR1cm4gZmFsc2U7CiAgICBmb3IgKGxvbmcgbG9uZyBpID0gNTsgaSAqIGkgPD0gbjsgaSArPSA2KSB7CiAgICAgICAgaWYgKG4gJSBpID09IDAgfHwgbiAlIChpICsgMikgPT0gMCkgcmV0dXJuIGZhbHNlOwogICAgfQogICAgcmV0dXJuIHRydWU7Cn0KCmludCBtYWluKCkgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUobnVsbHB0cik7IGNvdXQudGllKG51bGxwdHIpOwogICAgbG9uZyBsb25nIGEsIGI7ICBjaW4gPj4gYSA+PiBiOwogICAgbG9uZyBsb25nIGMgPSBhIC0gYjsKICAgIGlmIChjICE9IDEpIHsKICAgICAgICBjb3V0IDw8ICJOT1xuIjsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGxvbmcgbG9uZyBuID0gYSAqIGEgLSBiICogYjsgIAogICAgY291dCA8PCAobnQobikgPyAiWUVTXG4iIDogIk5PXG4iKTsKICAgIHJldHVybiAwOwp9Cg==