#include <bits/stdc++.h>
using namespace std;
map<int, int> m[13];
int n, k, a[200005];
int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = (X << 3) + (X << 1) + c - '0', c = getchar();
  return X * w;
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    long long x = a[i];
    for (int j = 1; j <= 10; j++) {
      x *= 10;
      x %= k;
      m[j][x]++;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int len = log10(a[i]) + 1;
    ans += m[len][(k - a[i] % k) % k];
    long long x = 1;
    for (int j = 1; j <= len; j++) x = x * 10;
    x %= k;
    if ((x * a[i] % k + a[i] % k) % k == 0) ans--;
  }
  printf("%I64d", ans);
}
