#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
ll modpow(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2, M);
        return t*t % M;
    }
    return N * modpow(N, P-1, M);
}
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll>ans(k + 1);
  for(int i = k; i > 0; i--){
    if(k / i == 1)ans[i] = 1;
    else{
      ans[i] = modpow(k / i,n,INF);
      ans[i] %= INF;
      for(int j = 2; i * j <= k; j++){
        if(ans[i] - ans[i * j] >= 0)ans [i] -= ans[i * j] % INF;
        else ans[i] = ans[i] - ans[i * j] + INF;
        ans[i] %= INF;
      }
    }
  }
  ll sum = 0;
  REP(i,1,k + 1){
    sum += (ans[i] % INF) * i;
    sum %= INF;
  }
  cout << sum << endl;
  return 0;
}
