#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
int n, K, a[N], len[N], y10[15];
map<int, int> b[11];
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int t1 = a[i];
    while (t1) len[i]++, t1 /= 10;
  }
  y10[1] = 10 % K;
  for (int i = 2; i <= 10; i++) y10[i] = y10[i - 1] * 10 % K;
  for (int i = 1; i <= 10; i++) b[i].clear();
  for (int i = 1; i <= n; i++) b[len[i]][a[i] % K]++;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      int t1 = ((long long)a[i] * y10[j] % K);
      t1 = (K - t1) % K;
      ans += b[j][t1];
    }
    int t2 = ((long long)a[i] * y10[len[i]] + a[i]) % K;
    if (t2 == 0) ans--;
  }
  printf("%lld", ans);
  return 0;
}
