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