#include<bits/stdc++.h> ##define int long long usingnamespace std; constint N = 2e6 + 10, MAXN = 2e6; int n, x, ans; int prim[N], cnt, phi[N]; bool st[N];
template<class T> inlinevoidread(T &x){ T res = 0, f = 1; char c = getchar(); while(! isdigit(c)) { if(c == '-') f = -1; c = getchar(); } while(isdigit(c)) res = (res << 1) + (res << 3) + c - 48, c = getchar(); x = res * f; return ; } template<class T, class ...T1> inlinevoidread(T &x, T1 &...x1){ read(x), read(x1...); return ; } template<class T> inlinevoidwrite(T x){ if(x < 0) x = -x, putchar('-'); if(x > 9) write(x / 10); putchar(x % 10 + 48); return ; } template<> inlinevoidwrite(char x){ putchar(x); return ; } template<class T, class ...T1> inlinevoidwrite(T x, T1 ...x1){ write(x),write(x1...); return ; }
#include<bits/stdc++.h> ##define int long long usingnamespace std; int n, m, ans;
template<class T> inlinevoidread(T &x){ T res = 0, f = 1; char c = getchar(); while(! isdigit(c)) { if(c == '-') f = -1; c = getchar(); } while(isdigit(c)) res = (res << 1) + (res << 3) + c - 48, c = getchar(); x = res * f; return ; } template<class T, class ...T1> inlinevoidread(T &x, T1 &...x1){ read(x), read(x1...); return ; } template<class T> inlinevoidwrite(T x){ if(x < 0) x = -x, putchar('-'); if(x > 9) write(x / 10); putchar(x % 10 + 48); return ; } template<> inlinevoidwrite(char x){ putchar(x); return ; } template<class T, class ...T1> inlinevoidwrite(T x, T1 ...x1){ write(x),write(x1...); return ; }
intqp(int a, int b){ int res = 1; while(b) { if(b & 1) res *= a; b >>= 1, a *= a; } return res; } intmu(int x){ int res = 1; for(int i = 2; i <= x / i; ++i) { if(x % i == 0) { res *= -1, x /= i; if(x % i == 0) return0; } } if(x > 1) res *= -1; return res; }
signedmain() { // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); read(n, m); for(int d = 1; d <= m / d; ++ d) if(m % d == 0) { ans += mu(d) * qp(m / d, n); if(d != m / d) ans += mu(m / d) * qp(d, n); } write(ans); return0; }
#include<bits/stdc++.h> ##define put putchar ##define LL long long usingnamespace std; constint N = 1e7 + 10, MAXN = 1e7; const LL mod = 20101009; LL n, m; int prim[N], cnt, mu[N]; LL sum[N]; bool st[N];
template<class T> inlinevoidread(T &x){ T res = 0, f = 1; char c = getchar(); while(! isdigit(c)) { if(c == '-') f = -1; c = getchar(); } while(isdigit(c)) res = (res << 1) + (res << 3) + c - 48, c = getchar(); x = res * f; return ; } template<class T, class ...T1> inlinevoidread(T &x, T1 &...x1){ read(x), read(x1...); return ; } template<class T> inlinevoidwrite(T x){ if(x < 0) x = -x, putchar('-'); if(x > 9) write(x / 10); putchar(x % 10 + 48); return ; } template<> inlinevoidwrite(char x){ putchar(x); return ; } template<class T, class ...T1> inlinevoidwrite(T x, T1 ...x1){ write(x),write(x1...); return ; }
LL qp(LL a, LL b){ a %= mod, b %= mod - 1; LL res = 1ll; while(b) { if(b & 1ll) res = res * a % mod; a = a * a % mod, b >>= 1; } return res; } voidinit(){ mu[1] = 1; for(int i = 2; i <= MAXN; ++ i) { if(! st[i]) prim[++ cnt] = i, mu[i] = -1; for(int j = 1; j <= cnt && prim[j] <= MAXN / i; ++ j) { st[prim[j] * i] = true; if(i % prim[j] == 0) break; mu[prim[j] * i] = -mu[i]; } } for(int i = 1; i <= MAXN; ++ i) sum[i] = sum[i - 1] + 1ll * i * i % mod * (mu[i] + mod) % mod, sum[i] %= mod; return ; } LL f(LL x){return x * (x + 1ll) / 2 % mod;} LL deal(LL n, LL m){ LL res = 0; for(LL l = 1, r; l <= n; l = r + 1) r = min(n / (n / l), m / (m / l)), res = (res + (sum[r] - sum[l - 1] + mod) % mod * f(n / l) % mod * f(m / l) % mod) % mod; return res; } LL get_ans(LL n, LL m){ if(n > m) swap(n, m); LL res = 0; for(LL l = 1, r; l <= n; l = r + 1) r = min(n / (n / l), m / (m / l)), res = (res + ((f(r) - f(l - 1) + mod)) % mod * deal(n / l, m / l) % mod) % mod; return res; }
#include<bits/stdc++.h> ##define LL long long usingnamespace std; constint N = 1e6 + 10, MAXN = 1e6; const LL mod = 1e9 + 7; int T, n, m, ans; int mu[N], f[N], g[N]; int prim[N], cnt, sum[N]; bool st[N + 10];
template<class T> inlinevoidread(T &x){ T res = 0, f = 1; char c = getchar(); while(! isdigit(c)) { if(c == '-') f = -1; c = getchar(); } while(isdigit(c)) res = (res << 1) + (res << 3) + c - 48, c = getchar(); x = res * f; return ; } template<class T, class ...T1> inlinevoidread(T &x, T1 &...x1){ read(x), read(x1...); return ; } template<class T> inlinevoidwrite(T x){ if(x < 0) x = -x, putchar('-'); if(x > 9) write(x / 10); putchar(x % 10 + 48); return ; } template<> inlinevoidwrite(char x){ putchar(x); return ; } template<class T, class ...T1> inlinevoidwrite(T x, T1 ...x1){ write(x),write(x1...); return ; }
intfp(int a, int b){ int res = 1; while(b) { if(b & 1) res = 1ll * res * a % mod; b >>= 1, a = 1ll * a * a % mod; } return res; }