#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (long long)1e9 + 7;
constexpr int loose = 0;
constexpr int tight = 1;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Edge {
  long long to, cap, rev;
  Edge(long long _to, long long _cap, long long _rev) {
    to = _to;
    cap = _cap;
    rev = _rev;
  }
};
void add_edge(vector<vector<Edge>>& G, long long from, long long to,
              long long cap, bool revFlag, long long revCap) {
  G[from].push_back(Edge(to, cap, (long long)G[to].size()));
  if (revFlag)
    G[to].push_back(Edge(from, revCap, (long long)G[from].size() - 1));
}
long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1LL;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long mod_inv(long long x, long long mod) {
  return mod_pow(x, mod - 2, mod);
}
long long gcd(long long m, long long n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
long long a[12][202020];
int b[202020];
void solve() {
  long long n, k;
  cin >> n >> k;
  for (int(i) = (int)(0); i < (int)(n); i++) cin >> b[i];
  map<int, int> mp[11];
  for (int(i) = (int)(0); i < (int)(n); i++) {
    a[0][i] = b[i] % k;
    for (int(j) = (int)(0); j < (int)(11); j++) {
      a[j + 1][i] = a[j][i] * 10 % k;
      mp[j][a[j][i]]++;
    }
  }
  long long ans = 0;
  for (int(i) = (int)(0); i < (int)(n); i++) {
    long long d = log10(b[i]) + 1;
    long long num = mp[d][(k - b[i] % k) % k];
    if (a[d][i] == (k - b[i] % k) % k) num--;
    ans += num;
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
