#include <bits/stdc++.h>
using namespace std;
inline unsigned decimalSize(unsigned val) {
  if (val > 999999999) return 10;
  if (val > 99999999) return 9;
  if (val > 9999999) return 8;
  if (val > 999999) return 7;
  if (val > 99999) return 6;
  if (val > 9999) return 5;
  if (val > 999) return 4;
  if (val > 99) return 3;
  if (val > 9) return 2;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  unsigned n, k;
  cin >> n >> k;
  vector<unsigned> a(n + 1);
  for (unsigned i = 1; i <= n; i++) cin >> a[i];
  vector<unordered_map<unsigned, unsigned>> rems(11);
  for (uint64_t i = 1; i <= n; i++) rems[decimalSize(a[i])][a[i] % k]++;
  uint64_t cnt = 0;
  for (uint64_t i = 1; i <= n; i++) {
    uint64_t val = a[i];
    for (uint64_t j = 1; j <= 10; j++) {
      val *= 10;
      unsigned rem = static_cast<unsigned>((k - (val % k)) % k);
      cnt += rems[j][rem];
      if (a[i] % k == rem && decimalSize(a[i]) == j) cnt--;
    }
  }
  cout << cnt << '\n';
  return 0;
}
