#include <bits/stdc++.h>
using namespace std;
namespace BANANA {
template <typename T>
inline void read(T &x) {
  x = 0;
  bool f = false;
  char in = getchar();
  while (!isdigit(in)) {
    if (in == '-') f = true;
    in = getchar();
  }
  while (isdigit(in)) x = x * 10 + in - '0', in = getchar();
  x = f ? -x : x;
}
inline void main() {
  int n, m;
  read(n), read(m);
  if (n > m) swap(n, m);
  bool f = true;
  for (int k = n + 1; k < m; ++k) {
    bool t = false;
    for (int i = 2; i * i <= k; ++i)
      if (k % i == 0) t = true;
    if (!t) f = false;
  }
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) f = false;
  for (int i = 2; i * i <= m; ++i)
    if (m % i == 0) f = false;
  puts(f ? "YES" : "NO");
}
}  // namespace BANANA
int main() {
  BANANA::main();
  return 0;
}
