#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n) {
  for (int i = 2; i < n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  int n, m, f = 1;
  cin >> n >> m;
  if (is_prime(m)) {
    for (int i = n + 1; i < m; i++) {
      if (is_prime(i)) {
        cout << "NO";
        f = 0;
        break;
      }
    }
    if (f) {
      cout << "YES";
    }
  } else {
    cout << "NO";
  }
  return 0;
}
