ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

USU Championship 2005

About     Problems     Submit solution     Judge status     Standings
Contest is over

K. Integer-Valued Complex Division

Time limit: 1.0 second
Memory limit: 64 MB
Let's introduce the operation of division with remainder on the ring of complex numbers with integer components. Let a be a dividend and b be a divisor. Then the result of the operation is any pair (q, r) satisfying the following conditions:
  1. b · q + r = a (here “·” and “+” are standard operations of multiplication and addition of complex numbers)
  2. |r| < |b|
It's evident that this operation is multivalued. You should output the number of different possible results of this operation for given dividend and divisor.

Input

There are two input lines. Each of them contains two integers, which are real and imaginary parts of a complex number, respectively. The absolute values of all the numbers do not exceed 106. The first line is the dividend and the second line is the divisor.

Output

Output the number of different possible results of the above-described operation.

Sample

inputoutput
12 0
0 5
2
Problem Author: Eugene Krokhalev
Problem Source: The Ural State University Championship, October 29, 2005
To submit the solution for this problem go to the Problem set: 1420. Integer-Valued Complex Division