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