#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, k, n, l, temp, pairs = 0;
  cin >> n >> k;
  vector<long long int> power10(12, 1);
  for (i = 1; i < 12; i++) {
    power10[i] = power10[i - 1] * 10;
  }
  vector<int> numbers(n);
  unordered_map<int, int> modCountDeci[11];
  for (int i = 0; i < 11; i++) modCountDeci[i].max_load_factor(0.25);
  for (i = 0; i < n; i++) {
    cin >> temp;
    numbers[i] = temp;
    temp = temp % k;
    for (j = 0; j < 11; j++) {
      modCountDeci[j][temp]++;
      temp = (10 * temp) % k;
    }
  }
  for (i = 0; i < n; i++) {
    temp = numbers[i];
    int digitlength = 0;
    long long int temp2 = temp;
    while (temp2 > 0) {
      temp2 /= 10;
      digitlength++;
    }
    temp = (k - (temp % k)) % k;
    if (modCountDeci[digitlength].count(temp) != 0) {
      pairs += modCountDeci[digitlength][temp];
      temp = (((power10[digitlength] % k) + 1) * temp) % k;
      if (temp == 0) {
        pairs--;
      }
    }
  }
  cout << pairs << endl;
}
