#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
double inff = 1.0 / 0.0;
unsigned long long int x, y, t, m, n, i, j, k, w, u, l, c;
unsigned long long int a[1000001];
vector<map<unsigned long long int, unsigned long long int>> v;
int main() {
  string str;
  cin >> n >> k;
  map<unsigned long long int, unsigned long long int> m1;
  for (i = (int)1; i < (int)11; i++) {
    v.push_back(m1);
  }
  if (n == 1) {
    cout << '0' << "\n";
    return 0;
  }
  for (i = (int)1; i < (int)n + 1; i++) {
    cin >> str;
    t = str.size();
    a[i] = (long long int)stoi(str);
    v[t - 1][((long long int)stoi(str)) % k]++;
  }
  for (w = (int)1; w < (int)n + 1; w++) {
    u = a[w] % k;
    str = to_string(a[w]);
    x = str.size();
    for (i = (int)0; i < (int)10; i++) {
      if (!v[i].empty()) {
        y = u * (long long int)pow(10, i + 1);
        j = y % k;
        auto itr = v[i].begin();
        if (j != 0)
          itr = v[i].find(k - j);
        else
          itr = v[i].find(0);
        if (itr != v[i].end()) {
          c += itr->second;
        }
      }
    }
    l = (u * (long long int)pow(10, x)) % k;
    if (l + u == k or l + u == 0) c--;
  }
  cout << c << "\n";
}
