// Arup Guha
// 6/29/2013
// Solution to 2012 Mid-Central Regional Contest Problem A: Pythagoras's Revenge.
import java.util.*;

public class a {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		long a = stdin.nextLong();

		// Go through each case.
		while (a != 0) {

			// Find all factors of a^2.
			ArrayList<Long> factorsAsq = allFactors(a*a);

			// Loop through all possible values of c - b. Remember a^2 = (c-b)(c+b).
			int cnt = 0;
			for (int i=0; i<factorsAsq.size()/2; i++) {

				// This sum should be twice c.
				long sum = factorsAsq.get(i) + a*a/factorsAsq.get(i);
				if (sum%2 != 0) continue;

				// Solve for b.
				long c = sum/2;
				long b = (a*a/factorsAsq.get(i) - factorsAsq.get(i))/2;

				// This is when we count it. Technically, we can just check b > a here.
				if ( (a*a)%(c-b) == 0 && (a*a)%(c+b) == 0 && b > a)
					cnt++;
			}

			// Solve and go to the next case.
			System.out.println(cnt);
			a = stdin.nextInt();
		}
	}

	public static ArrayList<Long> allFactors(long n) {

		ArrayList<Long> list = new ArrayList<Long>();

		// Build list of factors in pairs.
		long x = 1;
		while (x < Math.sqrt(n)-.01) {
			if (n%x == 0) {
				list.add(x);
				list.add(n/x);
			}
			x++;
		}

		// Only add for perfect squares.
		if (x*x == n)
			list.add(x);

		// Return sorted list.
		Collections.sort(list);
		return list;
	}
}