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