#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long INFF = 1e18;
const long long MAXN = 510;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
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);
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unordered_map<long long, long long, custom_hash> mp[11];
  long long n, k;
  cin >> n >> k;
  vector<long long> tab(n);
  for (auto &it : tab) cin >> it;
  const auto countDigit = [&](long long x) -> long long {
    if (x == 0) return 1;
    long long ret = floor(log10(x) + 1.0);
    return ret;
  };
  long long ans = 0;
  for (auto it : tab) {
    long long mod = it % k;
    long long need = (k - mod) % k;
    long long cnt = countDigit(it);
    ans += mp[cnt][need];
    long long pengali = 10;
    for (long long i = 1; i < 11; i++) {
      long long tot = (it * pengali) % k;
      mp[i][tot]++;
      pengali *= 10;
      pengali %= k;
    }
  }
  for (long long i = 1; i < 11; i++) mp[i].clear();
  reverse(tab.begin(), tab.end());
  for (auto it : tab) {
    long long mod = it % k;
    long long need = (k - mod) % k;
    long long cnt = countDigit(it);
    ans += mp[cnt][need];
    long long pengali = 10;
    for (long long i = 1; i < 11; i++) {
      long long tot = (it * pengali) % k;
      mp[i][tot]++;
      pengali *= 10;
      pengali %= k;
    }
  }
  long long hehe = 0;
  cout << ans << endl;
}
