#include <bits/stdc++.h>
using namespace std;
long long A[200010], sz[200010], v[200010][11];
vector<long long> l[11];
class Timer {
 private:
  using clock_t = std::chrono::high_resolution_clock;
  using second_t = std::chrono::duration<double, std::ratio<1> >;
  std::chrono::time_point<clock_t> m_beg;

 public:
  Timer() : m_beg(clock_t::now()) {}
  void reset() { m_beg = clock_t::now(); }
  double elapsed() const {
    return std::chrono::duration_cast<second_t>(clock_t::now() - m_beg).count();
  }
} T;
long long cnt(long long x) {
  long long r = 0;
  while (x) r++, x /= 10;
  return r;
}
void precompute(long long n, long long k) {
  for (long long i = 0; i < n; i++) {
    sz[i] = cnt(A[i]);
    long long x = A[i];
    v[i][0] = x;
    for (long long j = 1; j < 11; j++) x = (x * 10) % k, v[i][j] = x;
    A[i] %= k;
  }
}
void put(long long i) {
  l[sz[i]].push_back(A[i]);
  return;
}
long long binary(long long T, long long mod) {
  long long L = 0, R = (long long)l[T].size() - 1, ans1 = -1;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    if (l[T][mid] == mod)
      ans1 = mid, R = mid - 1;
    else if (l[T][mid] > mod)
      R = mid - 1;
    else
      L = mid + 1;
  }
  if (ans1 == -1) return 0;
  L = 0, R = (long long)l[T].size() - 1;
  long long ans2 = -1;
  while (L <= R) {
    long long mid = (L + R) >> 1;
    if (l[T][mid] == mod)
      ans2 = mid, L = mid + 1;
    else if (l[T][mid] > mod)
      R = mid - 1;
    else
      L = mid + 1;
  }
  return (ans2 - ans1 + 1);
}
long long get(long long idx, long long k) {
  long long ans = 0LL;
  for (long long i = 1; i < 11; i++) {
    long long x = v[idx][i];
    ans += binary(i, (k - x) % k);
    if (i == sz[idx] && (v[idx][i] + A[idx]) % k == 0) ans--;
  }
  return ans;
}
signed main() {
  long long n, k;
  scanf("%I64d %I64d", &n, &k);
  for (long long i = 0; i < n; i++) scanf("%I64d", &A[i]);
  precompute(n, k);
  for (long long i = 0; i < n; i++) put(i);
  for (long long i = 1; i < 11; i++) sort(l[i].begin(), l[i].end());
  long long ans = 0;
  for (long long i = 0; i < n; i++) ans += get(i, k);
  printf("%I64d\n", ans);
  return 0;
}
