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