#include <bits/stdc++.h>

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

struct Number{
    std::random_device rd;
    long long gcd(long long a, long long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    long long egcd(long long a, long long b, long long &x1, long long &y1) {
        if (!b) {
            x1 = 1;
            y1 = 0;
            return a;
        }
        long long x2, y2;
        long long r = egcd(b, a % b, x2, y2);
        x1 = x2 * 0 + y2 * 1;
        y1 = x2 * 1 - y2 *(a/b);
        return r;
    }
    int mod(string& str, int m) {
        int val = 0;
        for (auto c: str) {
            int a = c - '0';
            val = (1ll * val * 10 + a) % m;
        }
        return val;
    }
    int mul_mod(int a, int b, int m) {
        return a * 1ll * b % m;
    }
    long long mul_mod(long long a, long long b, long long m) {
        long long ans = 0;
        a %= m;
        b %= m;

        while (b) {
            if (b & 1ll) {
                ans = ans + a;
                if (ans >= m)
                    ans -= m;
            }
            a <<= 1;
            if (a >= m)
                a -= m;
            b >>= 1;
        }

        return ans;
    }
    int pow_mod(int a, int n, int m) {
        return pow_mod(a, 1ll * n, m);
    }
    int pow_mod(int a, long long n, int m) {
        if (n == 0)
            return 1 % m;
        if (n == 1)
            return a % m;
        int ans = pow_mod(a, n / 2, m);
        ans = 1ll * ans * ans % m;
        if (n % 2)
            ans = 1ll * ans * a % m;
        return ans;
    }
    long long pow_mod(long long a, long long n, long long m) {
        long long ans = 1;

        while (n) {
            if (n & 1) {
                ans = mul_mod(ans, a, m);
            }
            n >>= 1;
            a = mul_mod(a, a, m);
        }

        return ans;
    }
    int pow_mod(string&str1, string& str2, int m) {
        int p1 = mod(str1, m);
        int val = 1;
        for (auto c: str2) {
            val = pow_mod(val, 10, m);
            int tmp = pow_mod(p1, c - '0', m);
            val = mul_mod(val, tmp, m);
        }
        return val;
    }
    int divide_mod_with_fermat(int a, int b, int m) {
        int inv_b = modular_multiplicative_inverse_with_fermat(b, m);
        return 1ll * a * inv_b % m;
    }

    int divide_mod_with_egcd(int a, int b, int m) {
        int inv_b = modular_multiplicative_inverse_with_egcd(b, m);
        return 1ll * a * inv_b % m;
    }

    int modular_multiplicative_inverse_with_fermat(int a, int m) {
        return pow_mod(a, m - 2, m);
    }

    int modular_multiplicative_inverse_with_egcd(int a, int m) {
        long long x, y;
        long long g = egcd(a, m, x, y);
        if (g != 1)
            return -1;
        return (x % m + m) % m;
    }

    bool fermat_primality_test(long long n) {
        std::uniform_int_distribution<long long> dist(0, numeric_limits<long long>::max());
        if (n == 2 || n == 3)
            return true;
        if (n % 2  == 0)
            return false;
        if (n % 3 == 0)
            return false;
        for (int i = 0; i < 10; i++) {
            long long a = dist(rd) % (n - 4) + 2;
            long long val = pow_mod(a, n -1 , n);
            if (val != 1)
                return false;
        }
        return true;
    }

    bool miller_rabin_primality_test(long long n) {
        uniform_int_distribution<long long> dist(2, n - 2);
        if (n == 2 || n == 3)
            return true;
        if (n % 2 == 0)
            return false;
        if (n % 3 == 0)
            return false;
        int R = 0;
        long long D = n - 1;
        while (D % 2 == 0) {
            R += 1;
            D /= 2;
        }
        int cnt = 10;
        while (cnt--) {
            long long A = dist(rd);
            long long X = pow_mod(A, D, n);
            if (X == 1 || X == n - 1)
                continue;
            int flag = 0;
            for (int i = 1; i < R; i++) {
                X = mul_mod(X, X, n);
                if (X == 1)
                    return false;
                if (X == n - 1) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 1)
                continue;
            return false;
        }
        return true;
    }
};

Number number;

struct Prime {
    int upper;
    vector<int> prime;
    vector<int> A;

    Prime(int n) {
        upper = n;
        A.assign(n + 1, 1);
        A[0] = A[1] = 0;
        for (int i = 0; i <= n; i++)
            if (A[i])
                for (int j = i + i; j <= n; j += i)
                    A[j] = 0;
        for (int i = 0; i <= n; i++)
            if (A[i])
                prime.push_back(i);
        // cout << "prime: " << prime << endl;
    }

    bool is_prime(long long n) {
        if (n <= upper)
            return A[n];
        if (n < 2)
            return false;
        for (int i = 0; i < prime.size() && prime[i] <= sqrt(n); i++) {
            if (n % prime[i] == 0)
                return false;
        }
        return true;
    }

    void factor(long long n, map<long long, int>& M) {
        M.clear();
        for (int i = 0; i < prime.size() && prime[i] <= sqrt(n); i++) {
            while (n % prime[i] == 0) {
                M[prime[i]]++;
                n /= prime[i];
            }
        }
        if (n > 1)
            M[n]++;
    }

    void factor(long long n, vector<long long>& F) {
        F.clear();
        for (int i = 0; i < prime.size() && prime[i] <= sqrt(n); i++) {
            while (n % prime[i] == 0) {
                F.push_back(prime[i]);
                n /= prime[i];
            }
        }
        if (n > 1)
            F.push_back(n);
    }

    map<long long, int> _M;
    long long euler_totient(long long n) {
        map<long long, int>& M = _M; // memoery reuse
        factor(n, M);
        for (auto p: M)
            n = n / p.first * (p.first - 1);
        return n;
    }
    long long query_number_of_divisors(long long n) {
        map<long long, int>& M = _M; // memoery reuse
        factor(n, M);
        long long ans = 1;
        for (auto p: M)
            ans *= p.second + 1;
        return ans;
    }
    void backtrack_query_divisors(map<long long, int>& M, vector<long long>& P, int cur, long long val, vector<long long>& ans) {
        if (cur == P.size()) {
            ans.push_back(val);
            return;
        }
        long long p = P[cur];
        for (int i = 0; i <= M[P[cur]]; i++) {
            backtrack_query_divisors(M, P, cur + 1, val, ans);
            val *= p;
        }
    }
    vector<long long> _P;
    vector<long long> query_divisors(long long n) {
        map<long long, int>& M = _M; // memoery reuse
        vector<long long>& P = _P; // memory reuse
        factor(n, M);
        P.clear();
        for (auto p: M)
            P.push_back(p.first);
        vector<long long> ans;
        long long val = 1;
        backtrack_query_divisors(M, P, 0, val, ans);
        // sort(ans.begin(), ans.end());
        return ans;
    }
};

Prime prime(1e6);
int mod = 1e9 + 7;

int solve(int n, int k) {
    // cout << "n: " << n << ", k: " << k << endl;
    int ans = 0;
    for (int i = 1 ; i <= k; i++) {
        int val = number.pow_mod(k / i, n, mod);
        int euler = prime.euler_totient(i);
        // cout << "i: " << i << ", val: " << val << ", euler: " << euler << endl;
        ans += number.mul_mod(val, euler, mod);
        ans %= mod;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = solve(n, k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7616