#include <bits/stdc++.h>
using namespace std;
int k;
long long modTen[11];
int main() {
  int n;
  cin >> n >> k;
  vector<string> number(n);
  vector<int> digitNumber[10];
  vector<long long> modNumber(n);
  for (size_t i = 0; i < n; i++) {
    cin >> number[i];
    modNumber[i] = stol(number[i]) % k;
    digitNumber[number[i].size() - 1].emplace_back(modNumber[i]);
  }
  for (size_t i = 0; i < 10; i++) {
    sort(digitNumber[i].begin(), digitNumber[i].end());
  }
  modTen[0] = 1;
  for (size_t i = 1; i <= 10; i++) {
    modTen[i] = (modTen[i - 1] * (10 % k)) % k;
  }
  long long answer = 0;
  for (int i = 0; i < 10; i++) {
    if (digitNumber[i].size() > 0) {
      for (size_t j = 0; j < n; j++) {
        long long modB = (k - (modNumber[j] * modTen[i + 1]) % k) % k;
        auto leftBound =
            lower_bound(digitNumber[i].begin(), digitNumber[i].end(), modB);
        auto rightBound =
            upper_bound(digitNumber[i].begin(), digitNumber[i].end(), modB);
        answer += rightBound - leftBound;
        if (number[j].size() == i + 1 && modB == modNumber[j]) {
          answer -= 1;
        }
      }
    }
  }
  std::cout << answer << endl;
  return 0;
}
