#include <bits/stdc++.h>
using namespace std;
long long N, M;
vector<long long> A(100001, 0);
static int ntzhash[64];
void init_ntzhash() {
  unsigned long long h = 0x03F566ED27179461ULL;
  int i;
  for (i = 0; i < 64; i++, h <<= 1) ntzhash[h >> 58] = i;
}
int ntz_hash(unsigned long long n) {
  return n ? ntzhash[(int)(((n & -n) * 0x03F566ED27179461ULL) >> 58)] : 64;
}
int main(void) {
  scanf("%lld %lld", &N, &M);
  long long ans = 0;
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &A[i]);
    if (A[i] % M == 0) ++ans;
  }
  vector<long long> v(N + 1, 0);
  long long sum = 0;
  for (int i = 1; i <= N; ++i) sum += A[i], v[i] = sum;
  init_ntzhash();
  string s(N, '0');
  fill(s.end() - 2, s.end(), '1');
  do {
    string ss = s;
    int a, b;
    a = ntz_hash(stoull(ss, 0, 2));
    ss[(ss.size() - 1) - a] = '0';
    b = ntz_hash(stoull(ss, 0, 2));
    ++a, ++b;
    if ((v[b] - v[a - 1]) % M == 0) ++ans;
  } while (next_permutation(s.begin(), s.end()));
  printf("%lld\n", ans);
  return 0;
}
