#include <bits/stdc++.h>
using namespace std;
int u[101], n, m, b;
int main() {
  cin >> n >> m;
  u[1] = 1;
  for (int i = 2; i <= 100; i++)
    if (!u[i])
      for (int j = i * i; j <= 100; j += i) u[j] = 1;
  if (!u[n] && !u[m]) {
    for (int i = n + 1; i <= m - 1; i++)
      if (!u[i]) b = 1;
    if (!b) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
