#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t
#include <math.h>

#define BUF_SIZE 30

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define DIVISOR 1000000007
#define NUM_MAX 100000
// 2*3*7*11*13*15
#define DIVS_MAX 300
#define CNT_BIT_MAX 20
struct pair {
    int x;
    int y;
};

int asc(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}


void calc_power(uint64_t *powers, int size, int cnt) {
    int num,bit;
    uint64_t tmp[CNT_BIT_MAX] = {0};
    for(num = 0; num < size; num++) {
        uint64_t res = 1;
        tmp[0] = num;
        for(bit = 1; bit < CNT_BIT_MAX; bit++) {
            tmp[bit] = (tmp[bit-1]*tmp[bit-1])%DIVISOR;
        }
        for(bit = 0; bit < CNT_BIT_MAX; bit++) {
            if(!(cnt & (1<<bit))) continue;
            res = (res * tmp[bit])%DIVISOR;
        }
        powers[num] = res;
    }
    return;
}

int main(void) {
    int cnt, k;
    get_int2(&cnt, &k);
    int i;
    int cands[NUM_MAX+1] = {0};
    for(i = 1; i <= k; i++) {
        cands[i] = k/i;
    }
    uint64_t powers[NUM_MAX+1]; // (i)**(cnt)
    calc_power(powers, k+1, cnt);
    uint64_t ans = 0;
    int mod;
    for(mod = 1; mod <= k; mod++) {
        int mod2 = sqrt(0.5 + mod);
        int div;
        int sum = 0;
        // calc coef = (mod) - ((sum of mod's divs) - (mod))
        for(div = 1; div <= mod2; div++) {
            if(mod%div) break;
            sum += (div);
            if(div*div != mod) sum += (mod/div);
        }
        uint64_t coef = (mod*2 + DIVISOR - sum)%DIVISOR;
        ans = (ans + coef * powers[cands[mod]])%DIVISOR;
#ifdef DEBUG
        printf("[mod: %d] sum: %d => coef: %d ", mod, sum, mod*2-sum);
        printf(";; cands: %d, power: %llu\n", cands[mod], powers[cands[mod]]);
#endif
    }
    printf("%d\n", (int)ans);
    return 0;
}