#include <bits/stdc++.h>
using namespace std;
bool pr(int x) {
  bool p = 0;
  if (x % 2 == 0)
    p = (x == 2);
  else {
    long long d = 3;
    while (d * d <= x && x % d != 0) {
      d += 2;
    }
    if (d * d > x) p = (x != 1);
  }
  return p;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  bool fl;
  int n, m;
  cin >> n >> m;
  fl = pr(m);
  for (int i = n + 1; i < m; ++i) {
    if (pr(i)) {
      fl = 0;
    }
  }
  if (fl) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
