#include <bits/stdc++.h>
using namespace std;
int n;
long long k, b[200001], c[200001][10], cnt[10], num[200001][11];
long long a[200001][10];
vector<long long> d[11];
int bs(int i, long long M) {
  if (M == k) M = 0;
  int l = 0, r = cnt[i], m;
  while (l <= r) {
    m = (l + r) / 2;
    if (c[m][i] < M)
      l = m + 1;
    else {
      if (c[m][i] == M)
        return m;
      else
        r = m - 1;
    }
  }
  return -1;
}
void solve() {
  for (int i = 1; i < 11; i++) sort(d[i].begin(), d[i].end());
  for (int i = 1; i < 11; i++) {
    int t = 0, dem = 1;
    long long md = d[i][0];
    for (int j = 1; j < d[i].size(); j++) {
      if (d[i][j] != md) {
        num[t][i] = dem;
        c[t][i] = md;
        t++;
        dem = 0;
        md = d[i][j];
      }
      dem++;
    }
    num[t][i] = dem;
    c[t][i] = md;
    cnt[i] = t;
  }
  int j, m, pos;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    j = 0;
    m = b[i];
    while (m > 0) {
      j++;
      m /= 10;
    }
    pos = bs(j, (long long)k - b[i] % k);
    if (pos >= 0) ans += num[pos][j];
    if (a[i][j] == (k - b[i] % k) % k) ans--;
    ans = max(ans, (long long)0);
  }
  cout << max(ans, (long long)0);
}
void read() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> b[i], a[i][0] = b[i];
  for (int i = 0; i < n; i++) {
    long long m = 1;
    for (int j = 1; j < 11; j++) {
      m *= 10;
      a[i][j] = (long long)((b[i] % k) * (m % k)) % k;
      d[j].push_back(a[i][j]);
    }
  }
  solve();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  read();
}
