#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1000000007;
vector<unsigned long long> a(200005), b(200005), mul(11);
unordered_map<unsigned long long, unsigned long long> hsh[11];
unsigned long long getlen(unsigned long long a) {
  unsigned long long count = 0;
  while (a) {
    count++;
    a /= 10;
  }
  return count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long n, k, ans = 0;
  cin >> n >> k;
  for (unsigned long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = getlen(a[i]);
    a[i] = a[i] % k;
    hsh[b[i]][a[i]]++;
  }
  mul[0] = 1;
  for (int i = 1; i <= 10; i++) {
    mul[i] = (mul[i - 1] * 10) % k;
  }
  for (unsigned long long i = 0; i < n; i++) {
    for (unsigned long long j = 1; j <= 10; j++) {
      unsigned long long temp = (k - (a[i] * mul[j]) % k) % k;
      if (hsh[j].find(temp) != hsh[j].end()) {
        hsh[b[i]][a[i]]--;
        ans = ans + hsh[j][temp];
        hsh[b[i]][a[i]]++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
