#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
int n, k, i, d, l, r, j, s;
int c[10], a[maxn], b[10][maxn], h[maxn];
long long result, m;
int Length(int m) {
  int d;
  d = 0;
  while (m > 0) {
    d++;
    m /= 10;
  }
  return d;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  fill(c + 1, c + 11, 0);
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    d = Length(a[i]);
    c[d]++;
    b[d][c[d]] = a[i] % k;
    a[i] %= k;
    h[i] = d;
  }
  for (i = 1; i <= 10; i++) sort(b[i] + 1, b[i] + 1 + c[i]);
  result = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= 10; j++) {
      m = a[i];
      for (int z = 1; z <= j; z++) m = ((long long)10 * m) % k;
      s = (k - m) % k;
      l = lower_bound(b[j] + 1, b[j] + 1 + c[j], s) - b[j];
      r = upper_bound(b[j] + 1, b[j] + 1 + c[j], s) - b[j];
      if (s == a[i] && h[i] == j)
        d = r - l - 1;
      else
        d = r - l;
      result = result + (long long)d;
    }
  cout << result;
}
