#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6 + 5;
int a[MX], le[MX];
int n, k;
map<int, int> mp[11];
int getwei(long long x) {
  int wei = 0;
  while (x) {
    wei++, x /= 10;
  }
  return wei;
}
int main() {
  long long ten_pow[20];
  ten_pow[0] = 1;
  cin >> n >> k;
  for (int i = 1; i <= 11; i++) ten_pow[i] = ten_pow[i - 1] * 10LL % k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    le[i] = getwei(a[i]);
    mp[le[i]][a[i] % k]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    mp[le[i]][a[i] % k]--;
    for (int j = 1; j <= 10; j++) {
      long long now = k - (long long)a[i] * (ten_pow[j]) % k;
      auto it = mp[j].find((now == k ? 0 : now));
      if (it != mp[j].end()) ans += (long long)it->second;
    }
    mp[le[i]][a[i] % k]++;
  }
  cout << ans;
  return 0;
}
