#include <bits/stdc++.h>
using namespace std;
struct Key {
  unsigned long long N, p;
  bool operator==(const Key& other) const {
    return (N == other.N && p == other.p);
  }
};
struct KeyHasher {
  size_t operator()(const Key& k) const { return k.N * 59 + k.p * 61; }
};
unordered_map<Key, unsigned long long, KeyHasher> m;
unsigned long long tell(unsigned long long n) {
  unsigned long long d = 0;
  while (n) {
    d++;
    n /= 10;
  }
  return d;
}
int main() {
  vector<unsigned long long> t;
  unsigned long long K = 1;
  for (unsigned long long i = 0; i <= 10; i++, K *= 10) t.push_back(K);
  unsigned long long n, k;
  cin >> n >> k;
  vector<unsigned long long> v(n);
  for (unsigned long long i = 0; i < n; i++) {
    cin >> v[i];
    for (unsigned long long j = 0; j <= 10; j++) {
      unsigned long long p = v[i] * t[j];
      p %= k;
      m[{j, p}]++;
    }
  }
  unsigned long long ans = 0;
  for (unsigned long long i = 0; i < n; i++) {
    unsigned long long d = tell(v[i]);
    unsigned long long x = (k - (v[i] % k)) % k;
    ans += m[{d, x}];
    if ((v[i] * t[d]) % k == x) ans--;
  }
  cout << ans;
  return 0;
}
