#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int fun(long long int n) {
  long long int i = 0;
  while (n) {
    i++;
    n /= 10;
  }
  return i;
}
int main() {
  long long int i, j, k, l, m, n, t;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  long long int a[n], c[n];
  map<long long int, long long int> b[11];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    l = a[i] % m;
    k = fun(a[i]);
    for (j = 1; j <= 10; j++) {
      l *= 10;
      l %= m;
      b[j][l]++;
      if (j == k) {
        c[i] = l;
      }
    }
  }
  long long int answer = 0;
  for (i = 0; i < n; i++) {
    j = fun(a[i]);
    l = a[i] % m;
    l = (m - l) % m;
    k = b[j][l];
    if (l == c[i]) {
      k--;
    }
    answer += k;
  }
  cout << answer << endl;
  return 0;
}
