Input: N = 5, M = 7, nums = [6, 4, 5, 3, 7]
Output: 3
Explanation: First number will be 4 and the second will be 7, so the numbers between 4 and 7 are: [4, 5, 7]
Factors of 4 --> (1, 2, 4)
Factors of 5 --> (1, 5)
Factors of 7 --> (1, 7)
So, it contains every number from 1, 2, 3, 4, 5, 6, 7(as M = 7)
Input: N = 4, M = 2, nums = [3, 7, 2, 9]
Output: 0
Explanation: First number will be 2 and Second number is also 2
Factors of 2 --> (1, 2)
So it contains 1, 2(as M = 2)
Input: N = 3, M = 4, nums = [1, 3, 7]
Output: -1