#include <bits/stdc++.h>
using namespace std;
int a, b;
bool cond = 0;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a >> b;
  for (int i = 1; i <= a; i++) {
    for (int j = 2; j <= sqrt(a + i); j++) {
      if ((a + i) % j == 0) {
        cond = 1;
        break;
      }
    }
    if (cond != 1) {
      if (a + i == b) {
        cout << "YES";
      } else {
        cout << "NO";
      }
      return 0;
    }
    cond = 0;
  }
}
