#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n == 1) {
    return false;
  }
  if (n == 2 or n == 3) {
    return true;
  }
  if (n % 2 == 0 or n % 3 == 0) {
    return false;
  }
  for (int i = 5; i * i <= n; i += 6) {
    if (n % i == 0 or n % (i + 2) == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = n + 1; i < m; i++) {
    if (isPrime(i)) {
      cout << "NO";
      return 0;
    }
  }
  if (isPrime(m)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
