#include <bits/stdc++.h>
using namespace std;
bool isPrime(int x, int y) {
  vector<int> z(111);
  for (int i = (0); i < ((int)z.size()); i++) z[i] = 1;
  z[0] = 0;
  z[1] = 0;
  int j;
  for (int i = (2); i < ((int)z.size()); i++) {
    j = i + i;
    while (j < (int)z.size()) z[j] = 0, j += (i);
  }
  for (int i = (x + 1); i <= (y); i++) {
    if (z[i] == 1) {
      return i == y;
    }
  }
  return false;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  printf("%s", isPrime(n, m) ? "YES\n" : "NO\n");
  return 0;
}
