#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, string> mp;
bool isPrime(int n) {
  for (size_t i = 2; i < n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (size_t i = n + 1; i < m; i++) {
    if (isPrime(i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (isPrime(m)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
