#include <bits/stdc++.h>
using namespace std;
int cnt[100500];
int n, m, d;
int main() {
  scanf("%d %d", &n, &d);
  int pr[51];
  for (int i = 2; i <= 50; i++) pr[i] = 1;
  for (int i = 2; i <= 50; i++) {
    if (pr[i]) {
      for (int j = 2 * i; j <= 50; j += i) {
        pr[j] = 0;
      }
    }
  }
  for (int i = n + 1; i <= 50; i++) {
    if (pr[i]) {
      if (i == d) {
        printf("YES");
      } else {
        printf("NO");
      }
      return 0;
    }
  }
  printf("NO");
  return 0;
}
