#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #define _USE_MATH_DEFINES #include #include using namespace std; //#include //using namespace atcoder; #define REP(i,n) for(int i = 0; i < (int)n; i++) #define RREP(i,n) for(int i = (int)n-1; i >= 0; i--) #define LREP(i,n) for(LL i = 0; i < (LL)n; i++) #define Vi vector #define Vl vector #define LP pair #define P pair #define T3 tuple #define T4 tuple #define INF 1000000007 #define SIZE 300010 #define MOD 1000000007 typedef long long LL; int L, R; int parent[SIZE], s[SIZE]; void init() { for (int i = L; i <= R; i++) { parent[i] = i; s[i] = 1; } } int par(int a) { if (parent[a] == a) return a; else return parent[a] = par(parent[a]); } int size(int a) { int pa = par(a); return s[pa]; } void merge(int a, int b) { int pa = par(a), pb = par(b); if (pa != pb) { if (size(pa) > size(pb)) swap(pa, pb); parent[pa] = pb; s[pb] += s[pa]; } } bool same(int a, int b) { int pa = par(a), pb = par(b); if (pa == pb) return true; else return false; } int main() { cin >> L >> R; init(); for (int i = L; i <= R; i++) { for (int j = i; j <= R; j += i) { merge(i, j); } } set S; for (int i = L; i <= R; i++) { S.insert(par(i)); } cout << S.size() - 1 << endl; }