#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& out, pair<T, U> c) {
  out << "(" << c.first << " ";
  out << c.second << ")";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> c) {
  for (auto it = c.begin(); it != c.end(); ++it) {
    if (it != c.begin()) out << " ";
    out << *it;
  }
  return out;
}
template <class T>
ostream& operator<<(ostream& out, set<T> c) {
  for (auto it = c.begin(); it != c.end(); ++it) {
    if (it != c.begin()) out << " ";
    out << *it;
  }
  return out;
}
bool prime(int number) {
  bool t = true;
  for (int i = 2; i < number; i++) {
    if (number % i == 0) {
      t = false;
      break;
    }
  }
  return t;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int next = n + 1;
  while (true) {
    if (prime(next) == true) {
      break;
    } else {
      next++;
    }
  }
  if (next == m) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
