#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> R[11];
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    long long temp = a[i];
    while (temp) {
      cnt++;
      temp /= 10;
    }
    R[cnt][a[i] % k]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 10; j++) {
      long long addtoans = 0;
      long long temp = a[i], b = j;
      while (b--) temp *= 10, temp %= k;
      temp = k - temp;
      temp %= k;
      if (R[j].count(temp)) addtoans += R[j][temp];
      temp = a[i];
      b = j;
      while (b--) temp *= 10, temp %= k;
      temp %= k;
      long long tt = a[i];
      int countt = 0;
      while (tt) countt++, tt /= 10;
      if ((temp + a[i] % k) % k == 0 && countt == j) addtoans -= 1;
      ans += addtoans;
    }
  }
  cout << ans;
}
