#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  for (int i = 2; i < n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  int prime = false;
  for (int i = n + 1; i < m; i++) {
    if (isPrime(i)) {
      prime = true;
      break;
    }
  }
  printf(!prime && isPrime(m) ? "YES\n" : "NO\n");
}
