#include <bits/stdc++.h>
using namespace std;
const int M = 11, N = 2e5 + 5;
int n, k;
int a[N];
map<int, int> rem[M];
long long solve() {
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    unsigned long long f = 10;
    int ln = ((int)(to_string(a[i])).size());
    for (int l = 1; l < M; ++l) {
      int r = (k - (int)((f * a[i]) % k)) % k;
      ans += rem[l][r];
      if (l == ln && r == a[i] % k) ans--;
      f *= 10;
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    int l = ((int)(to_string(a[i])).size());
    rem[l][a[i] % k]++;
  }
  cout << solve() << '\n';
  return 0;
}
