#nullable enable using System.Numerics; void Run() { var k = long.Parse(String()); var n = long.Parse(String()); var ss = new HashSet(); for (var x = 1L; x <= 1000L; x++) for (var y = 1L; y <= 10000L; y++) { var u = x * x * x * x * x * x + y * y * y * y; if (u > n) continue; if (u % k != 0) continue; var v = u / k; var z = v.Root(2); if (z * z != v) continue; ss.Add(u); } Out(ss.Count); } #region var _io_ = new AtCoderIO(){ Backend = new() }; Run(); _io_.Backend.Flush(); string String() => _io_.Next(); int Int() => int.Parse(String()); void Out(object? x, string? sep = null) => _io_.Out(x, sep); class AtCoderIO { public required StandardIOBackend Backend { get; init; } ReadOnlyMemory _input = Array.Empty(); int _iter = 0; public string Next() { while (_iter >= _input.Length) (_input, _iter) = (Backend.ReadLine().Split(' '), 0); return _input.Span[_iter++]; } public void Out(object? x, string? separator = null) { if (x == null) return; separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable a and not string) { var objects = a.Cast(); if (separator == Environment.NewLine && !objects.Any()) return; x = string.Join(separator, objects); } Backend.WriteLine(x); } } class StandardIOBackend { readonly StreamReader _sr = new(Console.OpenStandardInput()); readonly StreamWriter _sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; public string ReadLine() => _sr.ReadLine()!; public void WriteLine(object? value) => _sw.WriteLine(value); public void Flush() => _sw.Flush(); } #endregion static class Extensions { public static T[] Repeat(this int time, Func F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); public static long Root(this long x, int root = 2) { var limits = new long[] { 0, 0, 3037000500L, 2097152, 55109, 6209, 1449, 512, 235, 128, 79, 53, 39 }; if (x < 0 || root < 2 || root >= limits.Length) throw new Exception("not supported"); var pass = 0L; var fail = limits[root]; while (fail - pass > 1) { var middle = (fail + pass) >> 1; var next = 1L; for (var i = 0; i < root; i++) next *= middle; if (next <= x) pass = middle; else fail = middle; } return pass; } }