#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
int gcd (int a,int b) {
   if (a >= b) {
       if (b == 0) {
           return a;
       }
       else {
           return gcd(b,a % b);
       }
   }
   else {
       return gcd(b,a);
   }
}
ll pow(ll a,ll n,ll d) {
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 1){
        return a * pow(a,n - 1,d) % d;
    }
    else {
        ll t = pow(a,n/2,d);
        return t * t % d;
    }
}
int main() {
    ll n,k;
    cin >> n >> k;
    ll ans[k + 1];
    for (ll i = k; i >= 1; i--) {
        ans[i] = pow(k / i, n , mod);
        int count = 2;
        while  (i * count < k + 1) {
            ans[i] -= ans[i * count];
            count++;
        }
    }
    ll ret = 0;
    for (int i = 1; i <= k; i++) {
        ret += ans[i] * i % mod;
    }
    cout << ret % mod ;
    return 0;
}