#include <bits/stdc++.h>
using namespace std;
long long n, k, a[200007], x, y, cnt = 0;
vector<map<long long, long long> > v(17);
map<long long, long long>::iterator it;
int main() {
  scanf("%lld%lld", &n, &k);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long i = 1; i <= n; i++) {
    for (long long p = 1, j = 10; p <= 10; p++, j *= 10) {
      x = ((a[i] % k) * (j % k)) % k;
      if (v[p].find(x) == v[p].end()) {
        v[p].insert(make_pair(x, 1));
      } else {
        v[p][x]++;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    x = 0;
    y = a[i];
    while (y != 0) {
      ++x;
      y /= 10;
    }
    if (v[x].find((k - (a[i] % k)) % k) != v[x].end()) {
      cnt += v[x][(k - (a[i] % k)) % k];
      if (((a[i] % k) * ((long long)pow(10, x) % k)) % k ==
          (k - (a[i] % k)) % k) {
        --cnt;
      }
    }
  }
  printf("%lld\n", cnt);
  return 0;
}
