#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 15;
long long a[maxn];
vector<unsigned long long> vv[15];
int main() {
  unsigned long long n, k;
  cin >> n >> k;
  unsigned long long cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int t = int(log10(a[i]) + 1);
    vv[t].push_back(a[i] % k);
    unsigned long long tmp = a[i] * pow(10, t);
    if ((tmp + a[i]) % k == 0) cnt--;
  }
  for (int i = 0; i < 15; i++) sort(vv[i].begin(), vv[i].end());
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < 15; j++) {
      unsigned long long tmp = a[i] * pow(10, j);
      unsigned long long kk = tmp % k;
      unsigned long long tt = k - kk;
      if (!kk) tt = kk;
      unsigned long long t1 =
          lower_bound(vv[j].begin(), vv[j].end(), tt) - vv[j].begin();
      unsigned long long t2 =
          lower_bound(vv[j].begin(), vv[j].end(), tt + 1) - vv[j].begin();
      cnt += (t2 - t1);
    }
  }
  cout << cnt << endl;
  return 0;
}
