import bisect def main(): import sys input = sys.stdin.read A = int(input().strip()) K = 4444 ** 4 # 4444^4 is the sum limit # Precompute residues and x^4 values residues = {} for x in range(1, 4444): r = pow(x, 3, 333) x4 = x ** 4 if r not in residues: residues[r] = [] residues[r].append(x4) # Sort each residue list for r in residues: residues[r].sort() total = 0 # Iterate over all a and b residues for a in range(333): alist = residues.get(a, []) if not alist: continue for b in range(333): blist = residues.get(b, []) if not blist: continue # Compute c residue c = (A - a - b) % 333 clist = residues.get(c, []) if not clist: continue # Check all x in a, y in b current = 0 for x4 in alist: for y4 in blist: s_xy = x4 + y4 if s_xy > K: continue remaining = K - s_xy # Count z4 in clist <= remaining cnt = bisect.bisect_right(clist, remaining) current += cnt total += current print(total) if __name__ == '__main__': main()