#include <bits/stdc++.h>
using namespace std;
bool isPrime(int num) {
  if (num <= 3) {
    return num > 1;
  } else if (num % 2 == 0 || num % 3 == 0) {
    return false;
  }
  for (int i = 5; i * i <= num; i = i + 6) {
    if (num % i == 0 || num % (i + 2) == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  int n, m;
  std::cin >> n >> m;
  int i = n + 1;
  bool found = false;
  while (!found && i <= m) {
    if (isPrime(i)) {
      found = true;
      break;
    }
    ++i;
  }
  if (i == m) {
    std::cout << "YES";
  } else
    std::cout << "NO";
  return 0;
}
