#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int dgt(int n) {
  int ans = 0;
  while (n) {
    ans++;
    n /= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int Pow[11];
  int n, k;
  scanf("%d %d", &n, &k);
  int a[n + 1];
  vector<vector<int> > digit(11);
  Pow[0] = 1;
  for (int i = 1; i <= 10; i++) Pow[i] = 10 * Pow[i - 1] % k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    digit[dgt(a[i])].push_back(a[i] % k);
  }
  long long int ans = 0;
  for (int i = 1; i <= 10; i++) sort(digit[i].begin(), digit[i].end());
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 10; j++) {
      long long int now = (long long int)a[i] * Pow[j] % k, need;
      if (now == 0)
        need = 0;
      else
        need = k - now;
      auto p = equal_range(digit[j].begin(), digit[j].end(), need);
      int d = (int)(p.second - p.first);
      ans += (long long int)d;
    }
    int need = (long long int)a[i] * Pow[dgt(a[i])] % k, now = a[i] % k;
    if (now + need == 0 || now + need == k) ans--;
  }
  printf("%lld\n", ans);
}
