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