#include <bits/stdc++.h>
using namespace std;
bool mark[200];
vector<int> primes;
int main() {
  primes.push_back(2);
  memset(mark, true, sizeof(mark));
  mark[0] = mark[1] = false;
  for (int i = 2; i * i <= 150; i++) {
    if (mark[i]) {
      for (int j = 2 * i; j <= 150; j += i) mark[j] = false;
    }
  }
  int n, m;
  cin >> n >> m;
  if (mark[m] == false) {
    cout << "NO\n";
    return 0;
  }
  bool ans = true;
  for (int i = n + 1; i < m; i++)
    if (mark[i]) {
      ans = false;
      break;
    }
  if (ans)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
