#include <bits/stdc++.h>
using namespace std;
int composite[51];
void precomp() {
  for (int i = 2; i < sqrt(51); i++) {
    if (composite[i] == 0) {
      for (int j = 2 * i; j < 51; j += i) {
        composite[j] = 1;
      }
    }
  }
}
int main() {
  precomp();
  int x, y;
  scanf("%d %d", &x, &y);
  int i;
  for (i = x + 1; composite[i] == 1; i++)
    ;
  if (i == y)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
