#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
using ll = int64_t;
using Pii = pair<int, int>;
using ull = uint64_t;
using Vi = vector<int>;
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  run();
  return 0;
}
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
Vi mods[10];
vector<Pii> counts[10];
int len(int first) {
  int m = 10;
  for (int i = 1;; i++) {
    if (first < m) return i;
    m *= 10;
  }
}
int getCount(int l, int first) {
  auto iter =
      lower_bound((counts[l]).begin(), (counts[l]).end(), make_pair(first, 0));
  if (iter != counts[l].end() && iter->first == first) {
    return iter->second;
  }
  return 0;
}
void run() {
  int n, k;
  cin >> n >> k;
  Vi elems(n);
  ll ans = 0;
  for (auto& e : (elems)) {
    cin >> e;
    uint64_t m = e;
    for (int i = (0); i < (10); i++) {
      m *= 10;
      mods[i].push_back(int(m % k));
    }
    ll tmp = 10;
    while (tmp <= e) tmp *= 10;
    uint64_t cand = uint64_t(e) * tmp + e;
    if (cand % k == 0) ans--;
  }
  for (int i = (0); i < (10); i++) {
    sort((mods[i]).begin(), (mods[i]).end());
    for (auto& m : (mods[i])) {
      if (counts[i].empty() || counts[i].back().first != m) {
        counts[i].push_back({m, 0});
      }
      counts[i].back().second++;
    }
  }
  for (auto& e : (elems)) {
    int m = e % k;
    if (m > 0) m = k - m;
    ans += getCount(len(e) - 1, m);
  }
  cout << ans << endl;
}
