#include <bits/stdc++.h>
using namespace std;
long long arr[1000000], po[11];
struct custom_hash {
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    x ^= FIXED_RANDOM;
    return x ^ (x >> 16);
  }
};
unordered_map<long long, long long, custom_hash> mp[11];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    long long d = 10;
    for (long long j = 1; j <= 10; j++) {
      po[j] = d;
      mp[j][(arr[i] * d) % k]++;
      d *= 10;
      d %= k;
    }
  }
  long long tot = 0;
  for (long long i = 0; i < n; i++) {
    string hi = to_string(arr[i]);
    long long yo = hi.size();
    long long asdf = arr[i] * po[yo];
    asdf %= k;
    long long u = arr[i] % k;
    u = k - u;
    u %= k;
    tot += mp[yo][u];
    if (asdf == u) tot--;
  }
  cout << tot;
  return 0;
}
