#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a;
int dig(unsigned long long n) {
  int res = 0;
  for (; n; n /= 10) res++;
  return res;
}
int main() {
  cin >> n >> k;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<unsigned long long> pw(11);
  pw[0] = 1;
  for (int i = 0; i < 10; i++) {
    pw[i + 1] = pw[i] * 10 % k;
  }
  map<unsigned long long, int> cnt[11];
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < n; j++) {
      cnt[i][(unsigned long long)a[j] * pw[i] % k]++;
    }
  }
  unsigned long long res = 0;
  for (int i = 0; i < n; i++) {
    unsigned long long x = a[i];
    unsigned long long mod = (k - x % k) % k;
    int d = dig(x);
    res += cnt[d][mod];
    if (((unsigned long long)x * pw[d] + x) % k == 0) res--;
  }
  cout << res << endl;
  return 0;
}
