#include <bits/stdc++.h>
using namespace std;
string ntos(long long n) {
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}
int main(void) {
  long long n, k;
  cin >> n >> k;
  vector<map<long long, long long> > v(11, map<long long, long long>());
  vector<long long> v1;
  for (long long i = (0); i < (n); ++i) {
    long long a;
    cin >> a;
    v1.push_back(a);
  }
  for (long long i = (1); i < (11); ++i) {
    long long a = ((long long)pow(10, i) % k);
    for (long long j = (0); j < (v1.size()); ++j) {
      long long b = (v1[j] % k) * a;
      long long c = b % k;
      v[i][c]++;
    }
  }
  long long ans = 0;
  for (long long i = (0); i < (v1.size()); ++i) {
    string s = ntos(v1[i]);
    long long a = s.size();
    long long b = (k - v1[i] % k) % k;
    ans += v[a][b];
    if ((v1[i] + (v1[i] % k) * ((long long)pow(10, a) % k)) % k == 0) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
