#include <bits/stdc++.h>
using namespace std;
bool prime(int p) {
  for (int i = 2; i < p; i++) {
    if (p % i == 0) return false;
  }
  return true;
}
int main() {
  int n, m, res;
  cin >> n >> m;
  for (int i = n + 1; i <= 50; i++) {
    if (prime(i)) {
      res = i;
      break;
    }
  }
  if (res == m)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
