import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n, k = map(int,input().split())
ans = int(k*(k+1)//2) #1種類のやつ

def function(n,k):
    if n < 1:
        return 0
    else:
        for i in range(1,k+1):
            ans += gcd(i,j) * math.factorial(n)
        return  ans + function(n-1)

for i in range(2,n+1): #2~n種類までループ
    for j in range(i+1,k+1):
        ans += gcd(i,j) * math.factorial(n) #数2種類
        for k in range(j+1,k+1):
            ans += gcd(i, j, k) * 6 #数3種類
    
print(function(n,k))
