#include <bits/stdc++.h>
using namespace std;
const int N = 100007;
int n, s[N];
vector<int> h[N];
void run() {
  int la, lb, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    s[i] = i * i;
    h[s[i] % N].push_back(s[i]);
  }
  la = (int)(n * sqrt(2.0) / 2) + 1;
  bool flag;
  int len;
  for (int i = 1; i <= la; i++) {
    lb = (int)sqrt(n * n - i * i * 1.0);
    for (int j = i; j <= lb; j++) {
      int tmp = (s[i] + s[j]) % N, key = s[i] + s[j];
      len = h[tmp].size();
      flag = false;
      for (int k = 0; k < len; k++) {
        if (h[tmp][k] == key) {
          flag = true;
          break;
        }
      }
      if (flag) ans++;
    }
  }
  printf("%d\n", ans);
}
int main() {
  run();
  return 0;
}
