#include <bits/stdc++.h>
using namespace std;
int viz[100], N, M, i, primes[100], nr, j;
void ciur() {
  primes[++nr] = 2;
  for (i = 3; i <= 100; i += 2) {
    if (viz[i]) continue;
    viz[i] = 1;
    primes[++nr] = i;
    for (j = i * i; j <= 100; j += i) viz[j] = 1;
  }
}
int main() {
  ciur();
  cin >> N >> M;
  for (i = 1; i < nr; i++)
    if (primes[i] == N)
      if (primes[i + 1] == M) {
        cout << "YES";
        return 0;
      }
  cout << "NO\n";
  return 0;
}
