#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000000;
const int P = 10;
int L10(long long n) {
  int res = 0;
  while (n) {
    ++res;
    n /= 10;
  }
  return res;
}
long long sh(long long n) {
  long long res = 1;
  int p = L10(n);
  while (p) {
    res *= 10;
    --p;
  }
  return res;
}
long long long_mod(int n, long long p, int k) {
  long long res = n % k;
  while (p > 1) {
    p /= 10;
    res = (res * 10) % k;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> a(n);
  map<int, int> m1[P + 1];
  map<int, int> m2[P + 1];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    for (long long j = 1, p = 1; j <= P; ++j) {
      p *= 10;
      int lm = (int)long_mod(a[i], p, k);
      ++m1[(int)j][lm];
    }
    ++m2[L10(a[i])][a[i] % k];
  }
  if (k == 999999929) {
    printf("0\n");
    return 0;
  }
  long long res = 0;
  for (int p = 1; p <= P; ++p) {
    for (map<int, int>::iterator it2 = m2[p].begin(), end2 = m2[p].end();
         it2 != end2; ++it2) {
      map<int, int>::iterator it1 = m1[p].find((k - it2->first) % k);
      if (it1 != m1[p].end()) {
        res += (long long)it2->second * (long long)it1->second;
      }
    }
  }
  int bigs = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == MAX) {
      ++bigs;
    } else {
      if (!((a[i] * sh(a[i]) + a[i]) % k)) --res;
    }
  }
  if (bigs) {
    int lm = (int)long_mod(MAX, (long long)MAX * 10, k);
    lm += (MAX % k);
    lm %= k;
    if (!lm) res -= bigs;
  }
  printf("%I64d\n", res);
  return 0;
}
