#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp[12];
long long a[200005], dig[200005];
long long state[200005][12];
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < n; i++) {
    dig[i] = log10(a[i]) + 1;
  }
  for (int i = 0; i < n; i++) {
    long long x = a[i];
    long long tencnt = 1;
    while (tencnt < 11) {
      x = (x * 10LL) % k;
      mp[tencnt][x]++;
      state[i][tencnt] = x;
      tencnt++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long len = dig[i];
    long long m = (k - (a[i] % k)) % k;
    if (mp[len].count(m) == 0) continue;
    ans += mp[len][m];
  }
  for (int i = 0; i < n; i++) {
    long long len = dig[i];
    long long x = state[i][len];
    if ((x + a[i]) % k == 0) {
      ans--;
    }
  }
  printf("%lld\n", ans);
}
