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