#include <bits/stdc++.h>
using namespace std;
int nextprime(int n);
bool isprime(int n);
int main() {
  int m = 0;
  int n = 0;
  cin >> n;
  cin >> m;
  cout << (m == nextprime(n) ? "YES" : "NO");
}
int nextprime(int n) {
  n++;
  while (!isprime(n)) {
    n++;
  }
  return n;
}
bool isprime(int n) {
  int i = 0;
  for (i = 2; i < n; i++) {
    if (n % i == 0) {
      break;
    }
  }
  return (i == n);
}
