#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long count = 0, a, b, n;
  cin >> a >> b >> n;
  while (a + b <= n) {
    if (a < b) {
      a += b;
    } else {
      b += a;
    }
    count++;
  }
  cout << count + 1 << '\n';
}
bool prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  if (!prime(m)) {
    cout << "NO";
    return 0;
  }
  for (int i = n + 1; i < m; ++i) {
    if (prime(i)) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
