#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int count = 0;
  if (isPrime(n) and isPrime(m)) {
    for (int i = n; i <= m; i++) {
      if (isPrime(i)) {
        count++;
      }
    }
    if (count == 2) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  } else {
    cout << "NO\n";
  }
  return 0;
}
