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

int64_t beki(int64_t n,int64_t x){
  vector<int64_t> vec(50);
  int64_t i,s,ans;
  i=0;
  ans=1;
  cin>>n>>x;
  while(x>0){
  vec.at(i)=x%2;
    x=x/2;
  i++;    
  }
  s=n;
  for(int64_t j=0;j<50;j++){
  if(vec.at(j)==1){ans=(ans*s)%1000000007;}  
   s=(s*s)%1000000007; 
   
  } return ans;}
  
 
  
int main() {
int64_t n,k,a;
  a=0;
  cin>>n>>k;
  vector<int64_t> dp(k);
  dp.at(0)=1;
  for(int64_t i=1;i<k;i++){
    dp.at(i)=beki(i+1,n);
 if(i>=2){ for(int64_t j=2;j<i+1;j++){
   dp.at(i)=dp.at(i)-dp.at(((i+1)/j)-1);
    if(dp.at(i)<0){dp.at(i)+=1000000007;}}
  }
  if(i==1){dp.at(i)=beki(2,n);}
    dp.at(i)--;
    if(dp.at(i)<0){dp.at(i)+=1000000007;}
  }
 for(int64_t i=0;i<k;i++){a+=dp.at((k/(i+1))-1)*(i+1);
                         while(a>=1000000007){a=a-1000000007;}}
  cout<<a<<endl;
  }