#include <bits/stdc++.h>
using namespace std;
bool isprime(int x) {
  int limit = sqrt(x);
  for (int i = 2; i <= limit; i++) {
    if (!(x % i)) return 0;
  }
  return 1;
}
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 2 && m == 3) {
    cout << "YES";
    return 0;
  }
  int i;
  for (i = n + 1; i <= m; i++) {
    if (isprime(i)) break;
  }
  if (i == m)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
