#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int N = 200005;
int n, k;
int a[N];
map<int, int> M[13];
long long ans;
int Count(int x) {
  int re = 0;
  while (x > 0) x /= 10, ++re;
  return re;
}
int Check(int x) {
  int l = Count(x);
  long long pw = 1;
  while (l--) pw *= 10;
  return (x % k * (pw % k) % k + x) % k == 0;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    int l = Count(a[i]);
    ++M[l][a[i] % k];
  }
  for (int i = 1; i <= n; ++i) {
    long long pw = 10;
    for (int j = 1; j <= 10; ++j) {
      int res = a[i] % k * (pw % k) % k;
      ans += M[j][(k - res) % k];
      pw = pw * 10;
    }
    if (Check(a[i])) --ans;
  }
  printf("%lld\n", ans);
  return 0;
}
