#include <bits/stdc++.h>
int main() {
  int n, m, i, j, k = 0, c = 0;
  scanf("%d%d", &n, &m);
  for (i = n + 1; i <= m; i++) {
    for (j = 2; j <= i / 2; j++) {
      if (i % j == 0) break;
    }
    if (i == m && j <= i / 2) {
      k = 1;
      break;
    }
    if (j > i / 2) {
      c = 1;
      break;
    }
  }
  if ((c && i != m) || (k))
    printf("NO");
  else
    printf("YES");
}
