using static System.Math; using System.Collections.Generic; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var k = long.Parse(line[0]); var n = long.Parse(line[1]); getAns(k, n); } static bool check(long t) { var w = (long)Sqrt(t); if (w * w == t) return true; w++; if (w * w == t) return true; return false; } static void getAns(long k, long n) { var hs = new HashSet(); for (long i = 1; i * i * i * i * i * i <= n; i++) { for (long j = 1; j * j * j * j <= n; j++) { var w = i * i * i * i * i * i + j * j * j * j; if (w % k == 0 && w / k > 0) { if (check(w / k) && w <= n) hs.Add(w); } } } Console.WriteLine(hs.Count); } }