#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  for (int i = 2; i <= n / 2; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int findNextPrime(int n) {
  bool found = false;
  int nextPrime = n;
  while (!found) {
    nextPrime++;
    if (isPrime(nextPrime)) {
      found = true;
    }
  }
  return nextPrime;
}
int main() {
  int n1, n2;
  cin >> n1 >> n2;
  int temp = findNextPrime(n1);
  if (temp == n2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
