#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
struct pair_hash {
  inline std::size_t operator()(
      const std::pair<long long, long long>& v) const {
    return v.first * 31 + v.second;
  }
};
const long long mod = 1e9 + 7;
vector<long long> binarycut(long long x) {
  vector<long long> v;
  while (x) {
    if (x & 1)
      v.emplace_back(1);
    else
      v.emplace_back(0);
    x >>= 1;
  }
  reverse(v.begin(), v.end());
  return v;
}
long long takemod(long long a, long long mod) {
  return ((a % mod) + mod) % mod;
}
long long fast_exp(long long base, long long expo) {
  long long res = 1;
  while (expo > 0) {
    if (expo & 1) res = (res * base) % mod;
    base = (base * base) % mod;
    expo >>= 1;
  }
  return res;
}
const long long N = 2e5 + 1;
long long a[N], rem[N * 12], lol[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  time_t t1, t2;
  t1 = clock();
  long long n, k;
  cin >> n >> k;
  unordered_map<long long, long long> m[12];
  for (long long i = 0; i < 12; i++) {
    m[i].reserve(2 * n);
  }
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    long long x = a[i];
    for (long long j = 1; j <= 11; j++) {
      x %= k;
      rem[i * 12 + j] = x;
      x *= 10;
    }
    lol[i] = to_string(a[i]).length();
    m[lol[i]][rem[i * 12 + 1]]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j <= 10; j++) {
      if (rem[i * 12 + j + 1] == 0) {
        ans += m[j][0];
        if (lol[i] == j && rem[i * 12 + 1] == 0) {
          ans--;
        }
      } else {
        ans += m[j][k - rem[i * 12 + j + 1]];
        if (lol[i] == j && rem[i * 12 + 1] == k - rem[i * 12 + j + 1]) ans--;
      }
    }
  }
  cout << ans << '\n';
  t2 = clock();
  cerr << "time taken: " << t2 - t1;
  return 0;
}
