#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  for (int i = 2; i < n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> vc;
  int sz = 50;
  int isBothPrime = 0;
  for (int i = 2; i <= 50; i++) {
    if (isPrime(i)) vc.push_back(i);
  }
  if (isPrime(n) == true and isPrime(m) == true) {
    isBothPrime = 1;
  }
  int ans = 0;
  if (isBothPrime == 1) {
    for (int i = 0; i < vc.size(); i++) {
      if (vc[i] == n) {
        if (vc[i + 1] == m) {
          ans = 1;
          break;
        }
      }
    }
  }
  ans == 1 ? cout << "YES" : cout << "NO";
  return 0;
}
