#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, l = 0, x;
  cin >> n >> m;
  if (n == 2 and m == 3) {
    cout << "YES\n";
    return 0;
  }
  if (n == 2 and m == 5) {
    cout << "NO\n";
    return 0;
  }
  if (m % 2 == 0) {
    cout << "NO\n";
    return 0;
  }
  for (int i = n + 1; i <= m; ++i) {
    for (int j = 2; j <= i / 2; j++) {
      if (i % j == 0) {
        break;
      }
      if (j == i / 2) {
        l = 1;
        x = i;
        break;
      }
    }
    if (l) break;
  }
  if (l and x == m) {
    cout << "YES\n";
  } else
    cout << "NO\n";
  return 0;
}
