#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
const int MAX2 = 11;
int v[MAX], pot10[MAX2];
unordered_map<int, int> mod[MAX2];
int digits(int n) {
  int res = 0;
  for (; n; n /= 10) res++;
  return res;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  pot10[0] = 1;
  for (int i = 1; i < MAX2; i++) pot10[i] = 1ll * 10 * pot10[i - 1] % k;
  for (int i = 0; i < MAX2; i++) {
    mod[i].max_load_factor(0.05);
  }
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  for (int i = 0; i < MAX2; i++)
    for (int j = 0; j < n; j++) mod[i][1ll * pot10[i] * v[j] % k]++;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = digits(v[i]);
    if (mod[tmp].count((k - v[i] % k) % k)) ans += mod[tmp][(k - v[i] % k) % k];
    if (1ll * (v[i] + (1ll * pot10[tmp] * v[i]) % k) % k == 0) ans--;
  }
  printf("%lld\n", ans);
  return 0;
}
