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