#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int nm = 0, fh = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') fh = -1;
  for (; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
  return nm * fh;
}
int n, mod, pw[200020], a[200020];
long long ans;
inline int get(int x) {
  int res = 0;
  while (x) x /= 10, res++;
  return res;
}
struct HASH {
  int tot, to[200020], cnt[200020], nt[200020], fs[999983];
  inline void Ins(int x) {
    for (int i = fs[x % 999983]; i; i = nt[i])
      if (to[i] == x) {
        cnt[i]++;
        return;
      }
    to[++tot] = x, cnt[tot] = 1, nt[tot] = fs[x % 999983], fs[x % 999983] = tot;
  }
  inline int qry(int x) {
    for (int i = fs[x % 999983]; i; i = nt[i])
      if (to[i] == x) return cnt[i];
    return 0;
  }
} Hs[11];
int main() {
  n = read(), mod = read(), pw[0] = 1;
  for (int i = 1; i <= 10; i++) pw[i] = 10ll * pw[i - 1] % mod;
  for (int i = 1; i <= n; i++) a[i] = read(), Hs[get(a[i])].Ins(a[i] % mod);
  for (int i = 1; i <= n; i++) {
    int now = ((long long)a[i] * pw[get(a[i])] % mod + a[i]) % mod;
    if (!now) ans--;
    for (int j = 1; j <= 10; j++) {
      int tmp = (long long)a[i] * pw[j] % mod, dat = (mod - tmp) % mod;
      ans += (long long)Hs[j].qry(dat);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
