#include <bits/stdc++.h>
using namespace std;
map<int, int> r[20];
int main() {
  long long n, k, a, b, c, d, e, f;
  long long m[200100], l[200100];
  scanf("%lld %lld", &n, &k);
  for (a = 0; a < n; a++) {
    scanf("%lld", &m[a]);
    l[a] = m[a] % k;
    c = 0;
    for (b = 1; c < 11; b *= 10, c++) {
      e = (l[a] * (b % k)) % k;
      if (r[c].count(e) > 0)
        r[c][e]++;
      else
        r[c][e] = 1;
    }
  }
  for (a = 0; a < n; a++) {
    b = 0;
    d = 1;
    b = ceil(log10(m[a] + 1));
    d = pow(10, b);
    e = (k - l[a]) % k;
    if (r[b].count(e) > 0) {
      f += r[b][e];
      if ((l[a] * (d % k)) % k == e) f--;
    }
  }
  cout << f;
}
