#include <bits/stdc++.h>
using namespace std;
long long expo(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent != 0) {
    if ((exponent & 1) == 1) {
      ans = ans * base;
      ans = ans % mod;
    }
    base = base * base;
    base %= mod;
    exponent >>= 1;
  }
  return ans % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j, n, k, a[200005], dig[200005], x, cnt;
  map<long long, map<long long, long long> > mm;
  map<long long, multiset<long long> > m;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    x = a[i];
    cnt = 0;
    while (1) {
      x /= 10;
      cnt++;
      if (x <= 0) {
        break;
      }
    }
    dig[i] = cnt;
  }
  for (i = 0; i < n; i++) {
    mm[dig[i]][(k - a[i] % k) % k]++;
    m[dig[i]].insert(a[i]);
  }
  long long ans = 0;
  for (i = 1; i <= 11; i++) {
    for (j = 0; j < n; j++) {
      long long tt = (a[j] % k * expo(10, i, k)) % k;
      ans += mm[i][tt % k];
      if (m[i].find(a[j]) != m[i].end() and (k - a[j] % k) % k == tt % k) {
        ans--;
      }
    }
  }
  cout << ans;
  return 0;
}
