#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200100], w[200100];
map<int, int> sum[12];
long long ans, p[12];
inline int read() {
  int x = 0, c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c & 15), c = getchar();
  return x;
}
inline int get(int x) {
  int ret = 0;
  while (x) x /= 10, ret++;
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  p[0] = 1;
  for (int i = 1; i <= 10; i++) p[i] = p[i - 1] * 10 % k;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    w[i] = get(a[i]);
    sum[w[i]][a[i] % k]++;
  }
  for (int i = 1; i <= n; i++) {
    sum[w[i]][a[i] % k]--;
    for (int j = 1; j <= 10; j++) {
      int x = (k - (a[i] * p[j]) % k) % k;
      if (sum[j].count(x)) ans += sum[j][x];
    }
    sum[w[i]][a[i] % k]++;
  }
  printf("%lld\n", ans);
  return 0;
}
