program test
implicit none
integer(8) :: n,k,tmp,list1(100000)=0,list2(100000)=0,i,ii,j,answer=0,big=1000000007,kenzan=0
integer(8) :: aa,bb,now_power,ans
read(*,*) n,k



do i=1,k
  tmp = int(k/i)
  
  aa = tmp
  bb = n
  now_power = 0
  ans = 1
  
  do while(bb > 0)
    do while(mod(bb,2**(now_power+1)) > 0)
      bb = bb - 2**(now_power)
      ans = mod(ans * aa,big)
    enddo
    now_power = now_power + 1
    aa = mod(aa * aa,big)
  enddo
  
  list1(i) = ans
enddo

list2 = list1

do i=k,1,-1
 ii=2*i
 do while(ii<=k)
   list2(i) = list2(i) - list2(ii)
   ii = ii + i
 enddo
enddo

do i=1,k
 answer = mod(answer+i*list2(i),big)
enddo

write(*,*) answer

end program
