#include <bits/stdc++.h>
using namespace std;
long long a[200001];
int main() {
  long long n, k;
  cin >> n >> k;
  long long ans = 0, len;
  int i, j;
  map<long long, long long> M[20];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    len = (long long)log10(a[i]) + 1;
    M[len][a[i] % k]++;
  }
  for (i = 0; i < n; i++) {
    unsigned long long x;
    long long mul = 1;
    len = (long long)log10(a[i]) + 1;
    M[len][a[i] % k]--;
    for (j = 1; j <= 10; j++) {
      mul *= 10;
      x = a[i] * mul;
      if (M[j].find((k - x % k) % k) != M[j].end())
        ans += M[j][(k - x % k) % k];
    }
    M[len][a[i] % k]++;
  }
  cout << ans << endl;
}
