#include <bits/stdc++.h>
using namespace std;
long long cnt_dig(long long x) {
  long long cnt = 0;
  while (x) {
    x /= 10;
    cnt++;
  }
  return cnt;
}
long long pmod(long long x, long long k) {
  long long ret = 1;
  for (int i = 0; i < x; i++) ret *= 10;
  ret %= k;
  return ret;
}
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<long long> dig(n);
  vector<long long> po(15);
  vector<map<long long, long long> > mp(11);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    dig[i] = cnt_dig(a[i]);
    a[i] = a[i] % k;
    if (mp[dig[i]].find(a[i]) == mp[dig[i]].end())
      mp[dig[i]][a[i]] = 1;
    else
      ++mp[dig[i]][a[i]];
  }
  for (int i = 0; i < 12; i++) po[i] = pmod(i, k);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    mp[dig[i]][a[i]]--;
    for (int j = 1; j <= 10; j++) {
      long long temp = (k - (a[i] * po[j]) % k) % k;
      if (mp[j].find(temp) != mp[j].end()) ans += mp[j][temp];
    }
    mp[dig[i]][a[i]]++;
  }
  cout << ans << "\n";
}
