#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long INF = 1e12;
const int MOD = 1e9 + 7;
void print() { cout << "\n"; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << "\n";
}
template <class T>
void print(set<T> &set) {
  for (auto &a : set) {
    cout << a << " ";
  }
  cout << "\n";
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto &vec : df) {
    print(vec);
  }
}
unsigned long long power(long long x, long long n) {
  unsigned long long ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}
long long comb(unsigned long long n, unsigned long long k) {
  vector<vector<long long>> v(n + 1, vector<long long>(n + 1, 0));
  for (unsigned long long i = 0; i < (unsigned long long)((v).size()); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (unsigned long long k = 1; k < (unsigned long long)((v).size()); k++) {
    for (unsigned long long j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
  return v[n][k];
}
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
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;
}
__attribute__((constructor)) void faster_io() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
unsigned long long n, k;
signed main() {
  cin >> n >> k;
  vector<unsigned long long> A(n), B(n);
  vector<unsigned long long> digits(n, 0);
  vector<vector<unsigned long long>> len(11);
  for (unsigned long long ni = 0; ni < (unsigned long long)(n); ni++) {
    unsigned long long v;
    cin >> v;
    A[ni] = v;
    B[ni] = v % k;
    while (v != 0) {
      v /= 10;
      digits[ni]++;
    }
    len[digits[ni]].push_back(B[ni]);
  }
  vector<vector<unsigned long long>> sec(n, vector<unsigned long long>(11, 0));
  vector<unsigned long long> mod_beki(11);
  mod_beki[0] = 1;
  for (unsigned long long i = 0; i < (unsigned long long)(10); i++) {
    mod_beki[i + 1] = mod_beki[i] * 10 % k;
  }
  for (unsigned long long ci = 0; ci < (unsigned long long)(11); ci++) {
    sort(len[ci].begin(), len[ci].end());
  }
  unsigned long long ans = 0;
  for (unsigned long long ni = 0; ni < (unsigned long long)(n); ni++) {
    unsigned long long fir = B[ni];
    for (unsigned long long ci = 0; ci < (unsigned long long)(11); ci++) {
      unsigned long long p = ((unsigned long long)fir * mod_beki[ci] % k);
      unsigned long long q = (k - p) % k;
      auto l = lower_bound(len[ci].begin(), len[ci].end(), q);
      auto r = upper_bound(len[ci].begin(), len[ci].end(), q);
      ans += r - l;
      if (digits[ni] == ci and (p + A[ni]) % k % k == 0) ans--;
    }
  }
  print(ans);
  return 0;
}
