#include <bits/stdc++.h>
using namespace std;
const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int pos(int num) {
  for (int i = 0; i < 15; i++) {
    if (num == primes[i]) return i;
  }
  return -1;
}
int main() {
  int n, m;
  cin >> n >> m;
  int pos_a = pos(n) + 1;
  if (m == primes[pos_a])
    cout << "YES\n";
  else
    cout << "NO\n";
}
