#include <bits/stdc++.h>
#pragma GCC optimize("3,Ofast,inline")
using namespace std;
unordered_map<int, int> M[11];
const int MAXN = 200011;
int a[MAXN];
int n, k;
long long ans;
inline int count(int x) {
  if (!x) return 1;
  int res = 0;
  while (x) {
    x /= 10;
    ++res;
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    int tmp = a[i], md = a[i] % k;
    int len = count(a[i]);
    for (int j = 1; j <= 10; ++j) {
      tmp = 10ll * tmp % k;
      tmp %= k;
      if (j == len && (tmp + md) % k == 0) {
        --ans;
      }
      M[j][tmp]++;
    }
  }
  for (int i = 1; i <= n; ++i) {
    int len = count(a[i]);
    ans += (long long)M[len][(k - a[i] % k) % k];
  }
  printf("%lld\n", ans);
  return 0;
}
