#include<bits/stdc++.h>
using namespace std;

int k, n, vis[100010] = {0};
vector<int> pri;
long long ans = 0;
const int M = 1e9 + 7;
int main() {
    cin >> k >> n;
    int m = sqrt(n + 0.5);
    memset(vis, 0, sizeof(vis));
    for(int i = 2; i <= m; i++) if(!vis[i])
        for(int j = i * i; j <= n; j += i) vis[j] = 1;
    for(int i = 1; i <= n; i++) if(!vis[i]) pri.push_back(i);
    for(int i = 1; i <= n; i++) {
        int l = 0, r = pri.size() - 1;
        while(l <= r) {
            int m = (l + r) >> 1;
            if(pri[m] * i > n) r = m - 1;
            else l = m + 1;
        }
        r++;
        long long s = 1, j = k;
        for(; j > 0; j >>= 1, r = r * r % M)
            if(j & 1) s = s * r % M;
        ans = (ans + s * i) % M;
    }
    cout << ans;
}