#include <bits/stdc++.h>
using namespace std;
int flag[32000], prime[32000], p = 0;
void seive(int n) {
  memset(flag, 0, sizeof(flag));
  int limit = sqrt(n) + 1;
  for (int i = 3; i < limit; i += 2) {
    if (flag[i] == 0) {
      for (int j = i * i; j < n; j += 2 * i) flag[j] = 1;
    }
  }
  prime[p++] = 2;
  for (int i = 3; i < n; i += 2) {
    if (flag[i] == 0) prime[p++] = i;
  }
}
int main() {
  seive(32000);
  int n, m, i, k = 0;
  cin >> n >> m;
  for (i = 0; i < p; i++) {
    if (prime[i] == n && prime[i + 1] == m) {
      k = 1;
      cout << "YES" << endl;
      break;
    }
  }
  if (k == 0) cout << "NO" << endl;
  return 0;
}
