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