There are teams in a software company. The team has employees in it and a total budget of units of money. Each team has to divide their budget within their employees equally. But for some teams, it's not possible to divide the budget equally.
Therefore, the company have to perform revisions in the teams' budget sizes.
In one revision, to revise the budget of team, the budget of the first teams has to be increased by .
Your task is to find the minimum number of revisions needed so that for each team, equal distribution of their budget among the employees is possible.
Constraints:
Input Format:
The first line contains an integer , denoting the number of teams.
Next lines contain two space-separated integers, and , each.
Output Format:
In a single line, print the minimum number of revisions needed so that for each team, equal distribution of their budget among the employees is possible.
Initially, the budges of the teams are , and .
In the first revision, the company will increase the budget for first teams by . This will make the budgets as , and .
In next revisions, the company will increase the budget of first teams by .
The final budgets will be , and which can now be equally distributed within each team.
You cannot achieve the equal distribution characteristic in less than four revisions.