#include <bits/stdc++.h>
using namespace std;
unsigned long long len(unsigned long long a) {
  unsigned long long count = 0;
  while (a > 0) {
    a = a / 10;
    count++;
  }
  return count;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  unsigned long long n, k;
  cin >> n >> k;
  unsigned long long a[n];
  for (unsigned long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  unordered_map<string, unsigned long long> mp;
  for (unsigned long long i = 0; i < n; i++) {
    unsigned long long l = len(a[i]);
    unsigned long long mod = a[i] % k;
    string obj = to_string(l);
    obj = obj + to_string(mod);
    mp[obj]++;
  }
  unsigned long long count = 0;
  for (unsigned long long i = 0; i < n; i++) {
    unsigned long long l = len(a[i]);
    unsigned long long mul = 10;
    unsigned long long ele = a[i];
    string obj = to_string(l);
    obj = obj + to_string(a[i] % k);
    mp[obj]--;
    for (unsigned long long j = 1; j <= 10; j++) {
      ele = ele * 10;
      unsigned long long mod = ele % k;
      unsigned long long req;
      if (mod != 0) {
        req = k - mod;
      } else {
        req = 0;
      }
      string p = to_string(j);
      p = p + to_string(req);
      if (mp.find(p) != mp.end()) {
        unsigned long long num = mp[p];
        count += num;
      }
    }
    mp[obj]++;
  }
  cout << count << '\n';
  return 0;
}
