#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  unsigned long long int n, k;
  cin >> n >> k;
  vector<unsigned long long int> v(n, 0);
  vector<unsigned long long int> digits(n, 0);
  map<int, unsigned long long int> m[11];
  for (unsigned long long int i = 0; i < n; ++i) {
    cin >> v[i];
    digits[i] = floor(log10(v[i]) + 1);
    m[digits[i]][v[i] % k]++;
  }
  unsigned long long int ans = 0;
  unsigned long long int pow[11];
  pow[0] = 1;
  for (int i = 1; i <= 10; ++i) {
    pow[i] = (pow[i - 1] * 10) % k;
  }
  for (unsigned long long int j = 0; j < n; ++j) {
    for (int i = 1; i <= 10; ++i) {
      unsigned long long int req = (k - ((v[j] * pow[i]) % k)) % k;
      ans += m[i][req];
      if ((digits[j] == i) && ((v[j] % k) == req)) {
        ans--;
      }
    }
  }
  cout << ans << endl;
}
