Under construction

Still being built. Things may change

Distinct Numbers

Interview

Time limit2sMemory limit512 MB

Summary
Given integers a and b, count how many distinct values appear among the ten expressions a+b, a-b, a*b, a/b, a^b and their swapped forms, skipping invalid ones.
Level

Medium4 of 10

Topics
Implementation, Math, Hash map, Brute force
Solved
No attempts yet

Problem

The other day Alice was cleaning her room and found a diary she kept in elementary school. In it she was surprised to find an entry about how amazed she was that 2+2=2⋅22 + 2 = 2 \cdot 2. Unbelievable, multiplication and addition give the same result!

That entry led Alice to the following problem. Given integers aa and bb, how many distinct values are there in the set of numbers

a+ba + b, a−ba - b, a⋅ba \cdot b, a/ba / b, aba^b,

b+ab + a, b−ab - a, b⋅ab \cdot a, b/ab / a, bab^a.

Division is performed without rounding, and the result of a division need not be an integer. If any expression in this set is invalid, Alice does not consider it. Division by zero and raising zero to a non-positive power count as invalid.

Input

The first line of the input file contains integers aa and bb separated by a space (∣a∣,∣b∣≤109|a|, |b| \le 10^9).

Output

Print the number of distinct numbers in the given set.

Examples2

  1. Example 1

    Input
    2 5
    
    Expected output
    8
    
  2. Example 2

    Input
    0 1
    
    Expected output
    3