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