from math import isqrt def issq(n): t = isqrt(n) return n > 0 and t * t == n K, N = map(int, input().split()) F = [] S = [] x = 1 while x**4 <= N: F.append(x**4) x += 1 y = 1 while y**6 <= N: S.append(y**6) y += 1 ans = 0 T = set() for f in F: for s in S: if f + s <= N: T.add(f+s) for t in T: if t%K == 0 and issq(t//K): ans += 1 print(ans)