// yuki 1593 Perfect Distance // 2021.8.11 #include #include typedef long long ll; int main() { int N, i, ans = 0; ll N2, j, t; scanf("%d", &N), N2 = (ll)N*N; int k = N/sqrt(2)+1; for (i = 1; i <= k; ++i) { t = N2-(ll)i*i; if (t < 0) continue; j = sqrt((double)t); if (j*j == t && i < j) ++ans; } printf("%d\n", 2*ans); return 0; }