Modular Equation

0

0 votes
Easy
Problem

Shashank loves modular equations. His friend Amit asks him a interesting problem. Shashank got confused and asks for your help.

Given 2 integers, A and B. Find the number of possible values of X, such that

A mod X = B mod X
Operation a mod b denotes taking a remainder after division of a by b.

If there are infinite possible values, print "infinity"

Input Format

First line contains 2 space separated integers, A and B

Output Format

Output a single integer, which is answer to the problem
If there are infinite solutions, output "infinity"

Constraints

  • 1 ≤ A, B ≤ 109
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Only 2 values of X satisfies the above equation.

  • X = 1, 5 mod 1 = 3 mod 1
  • X = 2, 5 mod 2 = 3 mod 2
Editor Image

?