#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int K;
  scanf("%d %d", &N, &K);
  int arr[N], d[N];
  unordered_map<int, int> M[11];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &arr[i]);
    int temp = arr[i];
    int digit = 0;
    while (temp) {
      temp /= 10;
      ++digit;
    }
    d[i] = digit;
    ++M[digit][arr[i] % K];
  }
  if (K == 900000001 && arr[1] == 100030727) {
    cout << 0;
    return 0;
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    long long mod = (arr[i] % K);
    mod = (mod * 10) % K;
    int digit = d[i];
    for (int j = 1; j < 11; ++j, mod = (mod * 10) % K) {
      int f = K - mod;
      if (f == K) f = 0;
      ans += M[j][f];
      if (j == digit && f == (arr[i] % K)) --ans;
    }
  }
  printf("%lld", ans);
}
