#include <stdio.h>

int memo[4][257][1<<15];

int count(int now,int prev,int rest) {
	int result=0;
	int i;
	if(rest==0)return 1;
	if(rest<0 || now>=4)return 0;
	if(memo[now][prev][rest]>0)return memo[now][prev][rest]-1;
	for(i=prev;i<=256 && i*i<=rest;i++) {
		result+=count(now+1,i,rest-i*i);
	}
	memo[now][prev][rest]=result+1;
	return result;
}

int main(void) {
	int query;
	while(1) {
		scanf("%d",&query);
		if(query==0)break;
		printf("%d\n",count(0,1,query));
	}
	return 0;
}