#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, count, num;
  scanf("%d%d", &n, &m);
  for (int i = n + 1; i <= m; i++) {
    count = 0;
    int s = sqrt(i);
    for (int j = 2; j <= s; j++) {
      if (i % j == 0) {
        count++;
        break;
      }
    }
    if (count == 0) {
      num = i;
      break;
    }
  }
  if (num == m)
    printf("YES");
  else
    printf("NO");
  return 0;
}
