#include <bits/stdc++.h>
using namespace std;
int n;
long long k;
long long a[200000 + 10];
long long m[10 + 10][200000 + 10];
int main() {
  scanf("%d%I64d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%I64d", &a[i]);
    m[0][i] = a[i] % k;
    for (int j = 1; j <= 10; ++j) m[j][i] = m[j - 1][i] * 10 % k;
  }
  for (int i = 1; i <= 10; ++i) sort(m[i], m[i] + n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long mod = (k - m[0][i]) % k;
    int w = 0;
    long long ttt = a[i];
    while (ttt > 0) {
      ++w;
      ttt /= 10;
    }
    ans += upper_bound(m[w], m[w] + n, mod) - lower_bound(m[w], m[w] + n, mod);
    mod = (k - mod) % k;
    while (w--) mod = mod * 10 % k;
    if ((mod + m[0][i]) % k == 0) --ans;
  }
  printf("%I64d\n", ans);
  return 0;
}
