#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, sum, k, ans[N];

int power(int a, int b, int m = mod){a %= m; if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int32_t main(){_
   
   cin >> n >> k;

   for (int i = k; i >= 1; --i)
   {
      int choose = power((k/i), n);
      ans[i] = choose;
      for (int j = 2*i; j <= k; j+=i)
      {
         ans[i] -= ans[j];
         ans[i] %= mod;
      }
   }
   
   for (int i = 1; i <= k; ++i)
   {
      sum += i * ans[i];
      sum %= mod;   
   }
      
   cout<<sum;

   return 0;
}