#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
long long tam(long long x) {
  long long r = 0;
  while (x > 0) {
    x /= 10;
    r++;
  }
  return r;
}
map<long long, long long> r[15];
long long pre[15];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > v(n);
  for (long long i = 0; i < n; i++) {
    long long aux;
    cin >> aux;
    v[i].first = tam(aux);
    v[i].second = aux % k;
  }
  pre[1] = 10 % k;
  for (long long i = 2; i <= 12; i++) {
    pre[i] = (pre[i - 1] * 10) % k;
  }
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long long sz = v[i].first;
    long long rest = v[i].second;
    r[sz][rest]++;
    if ((pre[sz] * rest + rest) % k == 0) {
      res--;
    }
  }
  for (long long i = 0; i < n; i++) {
    long long rest = v[i].second;
    for (long long sz = 1; sz <= 11; sz++) {
      long long now = (k - pre[sz] * rest) % k;
      while (now < 0) now += k;
      res += r[sz][now];
    }
  }
  cout << res << endl;
}
