#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long int digit(long long int num) { return floor(log10(num) + 1); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  vector<vector<long long int>> v(11), v2(11);
  vector<long long int> a(n + 1), p(11);
  p[0] = 1;
  for (int i = 1; i <= 10; i++) {
    p[i] = p[i - 1] * 10;
  }
  for (int i = 1; i <= n; i++) {
    long long int x;
    cin >> x;
    a[i] = x;
    for (int j = 0; j <= 10; j++) {
      v[j].push_back(((a[i] % k) * (p[j] % k)) % k);
    }
  }
  for (int i = 0; i < 11; i++) {
    vector<long long int> temp = v[i];
    sort(temp.begin(), temp.end());
    v2[i] = temp;
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    long long int toFind = k - a[i] % k;
    if (toFind == k) toFind = 0;
    long long int d = digit(a[i]);
    auto it1 = lower_bound(v2[d].begin(), v2[d].end(), toFind);
    auto it2 = upper_bound(v2[d].begin(), v2[d].end(), toFind);
    if (*(it2 - 1) == toFind) {
      ans += it2 - it1;
    }
  }
  for (int i = 1; i <= n; i++) {
    long long int d = digit(a[i]), toFind = k - a[i] % k;
    if (toFind == k) toFind = 0;
    if (v[d][i - 1] == toFind) ans--;
  }
  cout << ans << '\n';
  return 0;
}
