#include <bits/stdc++.h>
using namespace std;
long long size(long long r) {
  long long count = 0;
  while (r != 0) {
    r /= 10;
    count++;
  }
  return count;
}
int main() {
  long long n, k;
  cin >> n >> k;
  map<pair<long long, long long>, long long> m;
  long long arr[n];
  long long sizeofnum[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    sizeofnum[i] = size(arr[i]);
    m[make_pair(sizeofnum[i], arr[i] % k)]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long x = 1;
    for (long long j = 1; j <= 10; j++) {
      x = x * 10;
      long long mod = ((x % k) * (arr[i] % k)) % k;
      if (mod == 0) {
        if (j == sizeofnum[i] && (mod == (arr[i] % k)))
          ans += m[make_pair(j, mod)] - 1;
        else {
          if (m.find(make_pair(j, mod)) != m.end()) ans += m[make_pair(j, mod)];
        }
      } else {
        long long modi = k - mod;
        if (j == sizeofnum[i] && (modi == (arr[i] % k)))
          ans += m[make_pair(j, modi)] - 1;
        else {
          if (m.find(make_pair(j, modi)) != m.end())
            ans += m[make_pair(j, modi)];
        }
      }
    }
  }
  cout << ans << endl;
}
