#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 100;
int n;
unsigned long long k;
unsigned long long a[11][maxN];
unsigned long long res;
void enter() {
  scanf("%d%I64u", &n, &k);
  for (int i = 0; i < n; i++) scanf("%I64u", &a[0][i]);
}
void make_a() {
  for (int i = 1; i < 11; i++) {
    for (int j = 0; j < n; j++) a[i][j] = (a[i - 1][j] * 10ull) % k;
    sort(a[i], a[i] + n);
  }
}
int get_length(unsigned long long a) {
  int res = 0;
  while (a > 0) {
    res++;
    a /= 10ull;
  }
  return res;
}
bool concatenated(unsigned long long a, unsigned long long b) {
  int l = get_length(b);
  for (int i = 0; i < l; i++) a *= 10ull;
  return (a + b) % k == 0;
}
void solve() {
  res = 0;
  for (int i = 0; i < n; i++) {
    int l = get_length(a[0][i]);
    auto rng = equal_range(a[l], a[l] + n, (k - (a[0][i] % k)) % k);
    res += (unsigned long long)(rng.second - rng.first);
    if (concatenated(a[0][i], a[0][i])) res--;
  }
}
int main() {
  enter();
  make_a();
  solve();
  cout << res << endl;
}
