#include<stdio.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(){
  int n,m,i,j,M=1e9+7;
  long long ans=0,d[200010];
  scanf("%d %d",&m,&n);
  for(i=n;i;i--){
    d[i]=mbk(n/i,m,M);
    for(j=2;i*j<=n;j++)d[i]=(d[i]+M-d[i*j])%M;
    ans=(ans+(d[i]*i)%M)%M;//printf("%d %lld\n",i,d[i]);
  }
  printf("%lld\n",ans);
  return 0;
}
