#include <bits/stdc++.h>
using namespace std;
map<unsigned long long, unsigned long long> cnt[11];
int main() {
  unsigned long long N, K, len;
  unsigned long long cur;
  scanf("%lld %lld", &N, &K);
  unsigned long long arr[N];
  unsigned long long ans = 0;
  unsigned long long pows[11];
  pows[0] = 1;
  for (int i = 1; i < 11; i++) {
    pows[i] = pows[i - 1] * 10;
  }
  for (int i = 0; i < N; i++) {
    scanf("%lld", &arr[i]);
    cur = arr[i];
    for (int j = 1; j < 11; j++) {
      cur *= 10;
      cnt[j][cur % K]++;
    }
  }
  for (int i = 0; i < N; i++) {
    cur = arr[i];
    len = 1;
    while (cur / 10) {
      cur /= 10;
      len++;
    }
    cur = arr[i];
    if (cnt[len].find((K - cur % K) % K) == cnt[len].end()) continue;
    ans += cnt[len][(K - cur % K) % K];
    if (cur * pows[len] % K == ((K - cur % K) % K)) ans--;
  }
  printf("%lld\n", ans);
}
