#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
unsigned long long a[N], b[N];
int len[N];
map<int, int> m[11];
int main() {
  int k;
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int num = 0;
    cin >> a[i];
    int b = a[i];
    while (b) {
      b /= 10;
      num++;
    }
    len[i] = num;
    m[num][a[i] % k]++;
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; i++) {
    m[len[i]][a[i] % k]--;
    unsigned long long num = 1;
    unsigned long long temp = 0;
    for (int j = 1; j <= 10; j++) {
      num *= 10;
      temp = num * a[i];
      int vl = (k - temp % k) % k;
      if (m[j].count(vl)) ans += m[j][vl];
    }
    m[len[i]][a[i] % k]++;
  }
  cout << ans << endl;
  return 0;
}
