atcoder#ARC107B. [ARC107B] Quadruple

[ARC107B] Quadruple

Score : 400400 points

Problem Statement

Given are integers NN and KK. How many quadruples of integers (a,b,c,d)(a,b,c,d) satisfy both of the following conditions?

  • 1a,b,c,dN1 \leq a,b,c,d \leq N
  • a+bcd=Ka+b-c-d=K

Constraints

  • 1N1051 \leq N \leq 10^5
  • 2(N1)K2(N1)-2(N-1) \leq K \leq 2(N-1)
  • All numbers in input are integers.

Input

Input is given from standard input in the following format:

NN KK

Output

Print the answer.

2 1
4

Four quadruples below satisfy the conditions:

  • (a,b,c,d)=(2,1,1,1)(a,b,c,d)=(2,1,1,1)
  • (a,b,c,d)=(1,2,1,1)(a,b,c,d)=(1,2,1,1)
  • (a,b,c,d)=(2,2,2,1)(a,b,c,d)=(2,2,2,1)
  • (a,b,c,d)=(2,2,1,2)(a,b,c,d)=(2,2,1,2)
2525 -425
10314607400