#include <bits/stdc++.h>
using namespace std;
int get_len(int x) {
  int l = 0;
  while (x != 0) {
    l++;
    x /= 10;
  }
  return l;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<unordered_map<int, int> > table(12);
  for (int i = 0; i < n; i++) {
    int len = get_len(arr[i]);
    if (table[len].find(arr[i] % k) == table[len].end())
      table[len][arr[i] % k] = 1;
    else
      table[len][arr[i] % k]++;
  }
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < 11; j++) {
      long long int u = arr[i] % k;
      long long int v = pow(10, j);
      long long int a = ((u % k) * (v % k)) % k;
      int f = (k - a) % k;
      if (table[j].find(f) != table[j].end()) sum += table[j][f];
      if (get_len(arr[i]) == j && (a + (arr[i]) % k) % k == 0) sum--;
    }
  }
  cout << sum << "\n";
  return 0;
}
