#include <bits/stdc++.h>
using namespace std;
const int maxn = 205000;
map<long long, int> cnt[12];
long long n, k, ans, pre[20];
int a[maxn];
inline void insert(int x) {
  for (int i = 1; i <= 10; i++) cnt[i][(x * pre[i] % k)]++;
}
inline void calc(int x) {
  int len = 0;
  long long tmp = x;
  while (tmp) {
    len++;
    tmp /= 10;
  }
  if (cnt[len].count((k - x % k) % k) != 0) ans += cnt[len][(k - x % k) % k];
  if ((x * pre[len] + x) % k == 0) ans--;
}
int main() {
  scanf("%lld%lld", &n, &k);
  pre[0] = 1;
  for (int i = 1; i <= 15; i++) pre[i] = (pre[i - 1] * 10) % k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    insert(a[i]);
  }
  for (int i = 1; i <= n; i++) calc(a[i]);
  printf("%lld\n", max(ans, 0ll));
  return 0;
}
