#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
const int mod = 1000000007;
const int N = 3e5, M = N;
int max3(int a, int b, int c) {
  int ma = max(a, b);
  return max(ma, c);
}
vector<int> g[N];
int a[N];
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve() {
  int i = 0, j = 0, m, n, flag = 0, ans = 0;
  cin >> n >> m;
  for (i = n + 1; i < 51; i++) {
    if (isPrime(i)) {
      ans = i;
      break;
    }
  }
  if (ans == m)
    cout << "YES";
  else
    cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
