#include <bits/stdc++.h>
using namespace std;
void checkNextPrime(int n, int m) {
  while (1) {
    n++;
    int count = 0;
    for (int i = 1; i <= n; i++) {
      if (n % i == 0) count++;
    }
    if (count == 2) break;
  }
  if (n == m)
    cout << "YES";
  else
    cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  checkNextPrime(n, m);
  return 0;
}
