#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
map<int, int> rem[10 + 1];
void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<int> d(10 + 1), cf(N, 0);
  for (int i = 0; i < N; i++) {
    int n = a[i], c = 0;
    while (n) {
      n /= 10;
      c++;
    }
    rem[c][a[i] % K]++;
    cf[i] = c;
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    unsigned long long n = a[i];
    for (int j = 0; j <= 10; j++) {
      int r = n % K;
      if (r) r = K - r;
      ans += rem[j][r];
      if (cf[i] == j && a[i] % K == r) --ans;
      n = n * 10;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
