#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a;
  cin >> n >> m;
  for (int i = 1; i <= m - n; i++) {
    a = (n + i) / 2;
    int cnt = 0;
    for (int j = 2; j <= a; j++) {
      if ((n + i) % j == 0) {
        cnt++;
      }
    }
    if (cnt == 0) {
      if (m == n + i) {
        cout << "YES";
        break;
      } else {
        cout << "NO";
        break;
      }
    } else if (cnt != 0 && m == n + i) {
      cout << "NO";
    }
  }
}
