#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for(int i=0;i<A.size();i++){
        for(int k=0;k<B.size();k++){
            for(int j=0;j<B[0].size();j++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
            }
        }
    }
    return C;
}

mat marui(mat A, ll n){
    mat B(A.size(),vec(A.size()));
    for(int i=0;i<A.size();i++) B[i][i]=1;
    while(n>0){
        if(n&1) B=mul(B,A);
        A=mul(A,A);
        n>>=1;
    }
    return B;
}

ll yaku(ll a, ll b){
    if(a>b) return yaku(b,a);
    else{
        if(b%a==0) return a;
        else return yaku(b%a,a);
    }
}

int main(){
    ll N,K; cin>>N>>K;
    mat fn(K+1,vec(K+1,0));

    REP(i,1,K+1) REP(j,1,K+1) fn[i][yaku(i,j)]++;
    fn=marui(fn,N-1);
    ll ans=0;
    REP(i,1,K+1) REP(j,1,K+1) ans=(ans+fn[i][j]*j)%mod;
    cout<<ans<<endl;


}