#include <bits/stdc++.h>
using namespace std;
unsigned long long pirs_cnt(int n, unsigned long long k, vector<int> a) {
  map<int, int> m;
  vector<map<int, int>> cnts(11, m);
  int dig = 0;
  int num = a[n - 1];
  while (num > 0) {
    dig++;
    num /= 10;
  }
  cnts[dig][a[n - 1] % k] = 1;
  unsigned long long ans = 0;
  for (int i = n - 2; i >= 0; i--) {
    unsigned long long num2 = (unsigned long long)a[i];
    for (int j = 1; j <= 10; j++) {
      num2 *= 10;
      int rem = (int)(num2 % k);
      if (rem) {
        if (cnts[j].count(k - rem)) ans += (unsigned long long)cnts[j][k - rem];
      } else {
        if (cnts[j].count(0)) ans += (unsigned long long)cnts[j][0];
      }
    }
    dig = 0;
    num = a[i];
    while (num > 0) {
      dig++;
      num /= 10;
    }
    if (cnts[dig].count(a[i] % k))
      cnts[dig][a[i] % k]++;
    else
      cnts[dig][a[i] % k] = 1;
  }
  return ans;
}
int main() {
  int n;
  unsigned long long k;
  cin >> n >> k;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b(n, 0);
  for (int i = 0; i < n; i++) b[i] = a[n - 1 - i];
  cout << pirs_cnt(n, k, a) + pirs_cnt(n, k, b) << endl;
  return 0;
}
