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