#include <bits/stdc++.h>
using namespace std;
long long cha(long long x) {
  for (long long i = 1e9; i > 0; i /= 10) {
    if (x >= i) return i * 10;
  }
}
long long a[200010], b[200010], x[200010], z[20], s[20];
int main() {
  map<pair<long long, long long>, long long> vis;
  map<long long, long long> mm;
  long long n, m, i, j, sum = 0, k, p = 0;
  scanf("%lld%lld", &n, &k);
  z[0] = 1;
  for (i = 1; i <= 10; i++) {
    z[i] = (z[i - 1] * 10) % k;
    if (mm[z[i]] == 0) {
      s[p++] = z[i];
      mm[z[i]] = 1;
    }
  }
  for (i = 0; i < n; i++) scanf("%lld", &x[i]);
  vis.clear();
  for (i = 0; i < n; i++) {
    a[i] = cha(x[i]) % k;
    b[i] = x[i] % k;
    vis[{b[i], a[i]}]++;
  }
  for (sum = i = 0; i < n; i++) {
    vis[{b[i], a[i]}]--;
    for (j = 0; j < p; j++) {
      int t = (k - (b[i] * s[j]) % k) % k;
      if (vis.count({t, s[j]})) sum += vis[{t, s[j]}];
    }
    vis[{b[i], a[i]}]++;
  }
  printf("%lld\n", sum);
  return 0;
}
