#include void merge_sort(int n, int x[]) { static int y[10] = {}; if (n <= 1) return; merge_sort(n / 2, &(x[0])); merge_sort((n + 1) / 2, &(x[n/2])); int i, p, q; for (i = 0, p = 0, q = n / 2; i < n; i++) { if (p >= n / 2) y[i] = x[q++]; else if (q >= n) y[i] = x[p++]; else y[i] = (x[p] < x[q])? x[p++]: x[q++]; } for (i = 0; i < n; i++) x[i] = y[i]; } typedef struct List { struct List *next; int n, S; long long ans; } list; #define HASH 5000011 const int H_Mod = HASH; int hn = 0; list *hash[HASH] = {}, hd[20000000]; int hash_func(int n, int S) { return (((long long)n << 30) + S) % H_Mod; } long long pow[31]; long long recursion(int n, int a[], int S) { if (n == 0) return 1; int i; if (n == 1) { for (i = 1; pow[i] <= S; i++); return i - 1; } int h = hash_func(n, S); list *hp; for (hp = hash[h]; hp != NULL; hp = hp->next) if (hp->n == n && hp->S == S) break; if (hp != NULL) return hp->ans; hp = &(hd[hn++]); hp->n = n; hp->S = S; hp->ans = 0; hp->next = hash[h]; hash[h] = hp; long long x; for (i = 1, x = a[n]; x <= S; i++, x *= a[n]) hp->ans += recursion(n - 1, a, S - x); return hp->ans; } int main() { int i, n, S, a[10]; scanf("%d %d", &n, &S); for (i = 1; i <= n; i++) scanf("%d", &(a[i])); merge_sort(n, &(a[1])); for (i = 1, pow[0] = 1; pow[i-1] <= S; i++) pow[i] = pow[i-1] * a[1]; printf("%lld\n", recursion(n, a, S)); fflush(stdout); return 0; }