#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  for (int i = m + 1; i <= n; ++i) {
    bool isprime = true;
    for (int j = 2; j * j <= i; ++j)
      if (i % j == 0) isprime = false;
    if (isprime && i != n || !isprime && i == n) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
