#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x) {
  int t = 0;
  for (int i = 1; i < x; i++) {
    if (x % i == 0) t++;
  }
  if (t == 1)
    return true;
  else
    return false;
}
int main() {
  int n, m, fpan = 0;
  cin >> n >> m;
  if (is_prime(n) == 0 || is_prime(m) == 0)
    cout << "NO";
  else {
    for (int i = n + 1; i <= m; i++) {
      if (is_prime(i) == 1) {
        fpan = i;
        break;
      }
    }
    if (fpan == m)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
