import Foundation
let main: () = {
    let (N, K ) = *listOfInt()
    var dp = Array(K + 1) { _ in ModInt(0) }
    var ans = ModInt(0)
    for g in (1...K).reversed() {
        dp[g] = ModInt(K / g) ** N
        for p in stride(from: g * 2, through: K, by: g) {
            dp[g] -= dp[p]
        }
        ans += dp[g] * g
    }
    print(ans.value)
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
@inlinable func listOfInt(_ offset: Int = 0) -> [Int] { listOfString().map { Int($0)! + offset } }
extension Array {
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
}
extension Array where Element == Int {
    init(_ size: Int) {
        self = [Element]()
        for _ in 0 ..< size {
            self.append(0)
        }
    }
    @inlinable func joinToString(_ sepatator: String = " ") -> String { self.map { String($0) }.joined(separator: sepatator) }
}
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }

@inlinable func repeate(_ times1: Int, _ action: (Int) -> Void) {
    for index1 in 0 ..< times1 {
        action(index1)
    }
}


func turnpos(_ x: Int, _ y: Int) -> Int {
    var nx: Int
    var ratio: Int
    switch (x) {
    case ..<0:
        nx = -1 * x
        ratio = nx / y
        return (ratio + 1) * y + x
    default: return x // 0...
    }
}
func isprime(_ x: Int) -> Bool {
    switch (x) {
    case ...1: return false
    case ...3: return true
    default:
        var n = 2
        while n * n <= x {
            if x % n == 0 { return false }
            n += 1
        }
        return true
    }
}
func + (left: ModInt, right: ModInt) -> ModInt {  ModInt((left._value + right._value) % left._MOD) }
func - (left: ModInt, right: ModInt) -> ModInt { ModInt(turnpos((left._value - right._value) % left._MOD, left._MOD)) }
func * (left: ModInt, right: ModInt) -> ModInt { ModInt((left._value * right._value) % left._MOD) }
func / (left: ModInt, right: ModInt) -> ModInt { ModInt(left._value * right.pow(right._value, right._MOD - 2) % right._MOD) }
func + (left: ModInt, right: Int) -> ModInt { ModInt((left._value + right) % left._MOD) }
func + (left: Int, right: ModInt) -> ModInt { ModInt((right._value + left) % right._MOD) }
func += (left: inout ModInt, right: Int){ left = left + right }
func += (left: inout ModInt, right: ModInt){ left = left + right }
func - (left: ModInt, right: Int) -> ModInt { ModInt((left._value - right) % left._MOD) }
func - (left: Int, right: ModInt) -> ModInt { ModInt((left - right._value) % right._MOD) }
func -= (left: inout ModInt, right: Int) { left = left - right }
func -= (left: inout ModInt, right: ModInt) { left = left - right }
func * (left: ModInt, right: Int) -> ModInt { ModInt((left._value * right) % left._MOD) }
func * (left: Int, right: ModInt) -> ModInt { ModInt((left * right._value) % right._MOD) }
func *= (left: inout ModInt, right: Int) { left = left * right }
func *= (left: inout ModInt, right: ModInt) { left = left * right }
func / (left: ModInt, right: Int) -> ModInt { left / ModInt(right) }
func / (left: Int, right: ModInt) -> ModInt { ModInt(left) / right }
func /= (left: inout ModInt, right: Int) { left = left / right }
func /= (left: inout ModInt, right: ModInt) { left = left / right }
infix operator ** : BitwiseShiftPrecedence
func ** (left: ModInt, right: Int) -> ModInt { ModInt(left.pow(left._value, right)) }
func ** (left: ModInt, right: ModInt) -> ModInt { ModInt(left.pow(left._value, right._value)) }
func ** (left: Int, right: Int) -> Int { Int(pow(Double(left), Double(right))) }
prefix func - (left: ModInt) -> ModInt { ModInt(-1 * left._value) }
func == (left: ModInt, right: ModInt) -> Bool { (left._value - right._value) % left._MOD == 0 }
func != (left: ModInt, right: ModInt) -> Bool { !(left == right) }
func debugPrint(_ x: ModInt) { print("\(x._value) mod \(x._MOD)") }
func debugPrint(_ x: [ModInt]) { for (n, v) in x.enumerated() { print("[\(n)] \(v._value) mod \(v._MOD)") } }

class ModInt : Comparable, Equatable {
    let _MOD = 1_000_000_007
    static func < (lhs: ModInt, rhs: ModInt) -> Bool { lhs._value < rhs._value}
    var _value: Int
    init(_ value: Int = 0) {
        //if isprime(_MOD) == false { fatalError("The divisor should be prime!") }
        _value = value % _MOD
        if _value < 0 { _value = turnpos(_value, _MOD) }
    }
    func setv(newvalue: Int) {
        _value = newvalue % _MOD
        if _value < 0 { _value = turnpos(_value, _MOD) }
    }
    func getv() -> Int { _value }
    func getd() -> Int { _MOD }
    var value: Int { _value }
    func pow(_ a: Int, _ b: Int) -> Int {
        if (b == 0) { return 1 }
        if (b % 2 == 0) {
            let d = pow(a, b / 2)
            return (d * d) % _MOD
        }
        return a * pow(a, b - 1) % _MOD
    }
    func description() -> String { String(_value) }
}
