#include using namespace std; int N, M; int sqr[12345]; int main() { // freopen("date.in", "r", stdin); // freopen("date.out","w", stdout); cin.sync_with_stdio(false); memset(sqr, -1, sizeof(sqr)); for (int i = 0; i * i < 12345; i++) { sqr[i * i] = i; } while (cin >> M >> N) { int ans = 0; for (int x = 0; x <= M; x++) { for (int y = x; y <= M; y++) { int sum = x * x + y * y; int z = sqr[sum]; if (z != -1 && z >= y && z <= M) { ans++; } } } ans += (M + 1) * (N - 2); cout << ans << '\n'; } return 0; }