#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int flag[10000];
void sieve() {
  int i, j;
  flag[1] = 1;
  flag[0] = 1;
  int sq = sqrt(10000);
  for (i = 4; i <= 10000; i += 2) {
    flag[i] = 1;
  }
  for (i = 3; i <= sq; i += 2) {
    if (flag[i] == 0) {
      for (j = i * i; j <= 10000; j += 2 * i) {
        flag[j] = 1;
      }
    }
  }
  for (i = 1, j = 1; i <= 1000; i++) {
    if (flag[i] == 0) {
      m[j] = i;
      j++;
    }
  }
}
int main() {
  int i;
  int a, b, f;
  sieve();
  while (scanf("%d%d", &a, &b) == 2) {
    f = 0;
    for (i = 1; i <= 100; i++) {
      if (m[i] == a && m[i + 1] == b) {
        printf("YES\n");
        f = 1;
        break;
      }
    }
    if (f == 0) printf("NO\n");
  }
  return 0;
}
