Canadian Computing Competition: 2011 Stage 1, Junior #3
In a sumac sequence, , each term is an integer greater than or equal . Also, each term, starting with the third, is the difference of the preceding two terms (that is, for ). The sequence terminates at if .
For example, if we have and , then the sumac sequence generated is as follows:
This is a sumac sequence of length .
The input will be two positive numbers and , with .
The output will be the length of the sumac sequence given by the starting numbers and .
Output for Sample Input