#include <bits/stdc++.h>
using namespace std;
long long a[200020], p[11];
int l[200020];
int main(void) {
  int n;
  long long k;
  int i, j;
  map<long long, long long> s[11];
  long long o, t;
  scanf("%d %I64d", &n, &k);
  for (i = 0; i < 11; i++) s[i].clear();
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    l[i] = log10(a[i]) + 1;
    a[i] %= k;
    ++s[l[i]][a[i]];
  }
  for (i = p[0] = 1; i <= 10; i++) p[i] = p[i - 1] * 10 % k;
  for (i = 1, o = 0; i <= n; i++) {
    for (j = 1; j <= 10; j++) {
      t = a[i] * p[j] % k;
      if (t) t = k - t;
      o += s[j][t];
      o -= j == l[i] && t == a[i];
    }
  }
  printf("%I64d\n", o);
  return 0;
}
