#include <stdio.h>
#include <math.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int main(void){
    // Your code here!
    int  i,j,N,K,count;
    int mod = 1e9+7;
    long long sum;
    long long del[100020];
    sum = 0;
    scanf("%d %d",&K,&N);
    for(i=N;i>0;i--){
        count = N/i;
        del[i] = mbk(count,K,mod);
        if(count >1){
        for(j=2;j<=count;j++){
            del[i]= del[i] - del[i*j];
        }
        }
        sum = (sum + mod +( i*del[i]))%mod;
    //printf ("i%d del%d %d\n",i,del[i],sum);
    }
    printf ("%lld",sum);
    return 0;
}