import math from sys import stdin n, m, *a = map(int, stdin.read().split()) divideset = set() for i in range(1,int(math.floor(math.sqrt(m)))+2): if m % i == 0: divideset.add(i) divideset.add(m//i) dividelist = list(divideset) dividelist.sort() dividedict = dict() nd = len(dividelist) for i in range(nd): dividedict[dividelist[i]] = i for i in range(n): kari = math.gcd(a[i],m) a[i] = kari dp = [[0 for i in range(nd)] for j in range(n+1)] dp[0][0] = 1 for i in range(n): for j in range(nd): kari = a[i] * dividelist[j] val = math.gcd(kari,m) dp[i+1][j] += dp[i][j] dp[i+1][dividedict[val]] += dp[i][j] ans = dp[n][nd-1] print("{}".format(ans))