Consider a real polynomial P(x,y) in two variables. We call it invariant under the rotation by an angle α if
P(xcosα−ysinα,xsinα+ycosα)=P(x,y)
holds for all real x and y.
Consider the real vector space of all two-variable polynomials of degree at most d that are invariant under the rotation by 2π/n. Compute the dimension M of this vector space.
You may find the following remark useful: every polynomial of degree at most d can be written uniquely as
P(x,y)=∑i,j≥0i+j≤daijxiyj
for some real coefficients aij.
A single line with two positive integers d and n separated by one space. Both are less than 1000.
Output a single integer M, the dimension of the vector space described above.