#include <bits/stdc++.h>
using namespace std;
bool prime(int n) {
  bool x = 0;
  for (int i = 2; i < n; i++)
    if (n % i == 0) x = 1;
  if (x)
    return 0;
  else
    return 1;
}
int main() {
  int n, m, x = 1;
  cin >> n >> m;
  bool b;
  for (int i = n + 1; i <= m; i++) {
    b = prime(i);
    if (b && i != m) {
      x = 1;
      break;
    }
    if (b && i == m) x = 2;
  }
  if (x == 1)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
