#include <bits/stdc++.h>
using namespace std;
long long n, k, A[200006], len[200006], limit, ans;
vector<long long> v[15];
int main() {
  if (1 - 1) freopen("in.cpp", "r", stdin);
  cin >> n >> k;
  if (1 - 1) cout << n << ' ' << k << '\n';
  for (long long i = 0; i < n; i++) cin >> A[i];
  if (1 - 1)
    for (long long i = 0; i < n; i++) cout << A[i] << ' ';
  if (1 - 1) cout << "\n";
  for (long long i = 0; i < n; i++) {
    len[i] = ((long long)log10(A[i])) + 1;
    limit = max(limit, len[i]);
    v[len[i]].push_back(A[i] % k);
  }
  if (1 - 1) cout << limit << '\n';
  for (long long i = 0; i < 13; i++) {
    sort(v[i].begin(), v[i].end());
    if (1 - 1) cout << "i: " << i << '\n';
    if (1 - 1)
      for (auto j : v[i]) cout << j << '\n';
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j < limit + 1; j++) {
      if (v[j].empty()) continue;
      long long num = (long long)(A[i] % k * ((long long)pow(10, j) % k)) % k;
      long long left = (k - num) % k;
      auto l = lower_bound(v[j].begin(), v[j].end(), left);
      if (l == v[j].end() || *l != left) continue;
      auto r = prev(upper_bound(v[j].begin(), v[j].end(), left), 1);
      ans += (r - v[j].begin()) - (l - v[j].begin()) + 1;
      if (j == len[i] && *l == A[i] % k) ans--;
    }
  }
  cout << ans << '\n';
}
