#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long v[N];
vector<pair<int, int> > g[11];
int len(int x) {
  int c = 0;
  while (x) {
    x /= 10;
    c++;
  }
  return c;
}
int n, k;
long long ans = 0;
void mul(int m) {
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    v[i] = (v[i] * 10) % k;
    mp[v[i]]++;
  }
  for (auto x : g[m]) {
    int temp = x.first % k, in = x.second;
    ans += mp[(k - temp) % k];
    if ((k - temp) % k == v[in]) ans--;
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    g[len(v[i])].push_back({v[i], i});
  }
  for (int i = 1; i <= 10; i++) {
    mul(i);
  }
  cout << ans << endl;
  return 0;
}
