#include <bits/stdc++.h>
using namespace std;
int numb(long long x) {
  int sum = 0;
  long long y = x;
  while (y > 0) {
    sum++;
    y = y / 10;
  }
  return sum;
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long schet[11][n];
  for (int i = 0; i < n; i++) {
    schet[0][i] = a[i] % k;
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 0; j < n; j++) {
      schet[i][j] = (schet[i - 1][j] * 10) % k;
    }
  }
  for (int i = 0; i <= 10; i++) {
    sort(schet[i], schet[i] + n);
  }
  long long otvet = 0;
  for (int j = 0; j < n; j++) {
    int x = numb(a[j]);
    int l = 0;
    int r = n - 1;
    int aba = a[j] % k;
    int poisk = (k - aba) % k;
    while (r - l > 1) {
      int sr = (l + r) / 2;
      if (schet[x][sr] > poisk) {
        r = sr;
      } else {
        l = sr;
      }
    }
    int ans1 = r;
    long long itec;
    for (int i = 2; i >= -2; i--) {
      itec = max(ans1 + i, 0);
      itec = min(itec, n - 1);
      if (schet[x][itec] == poisk) {
        break;
      }
    }
    ans1 = itec;
    l = 0;
    r = n - 1;
    while (r - l > 1) {
      long long sr = (l + r) / 2;
      if (schet[x][sr] >= poisk) {
        r = sr;
      } else {
        l = sr;
      }
    }
    int ans2 = l;
    int kek = 1;
    for (int i = -2; i <= 2; i++) {
      itec = max(ans2 + i, 0);
      itec = min(itec, n - 1);
      if (schet[x][itec] == poisk) {
        kek = 0;
        break;
      }
    }
    ans2 = itec;
    if (kek == 0) {
      otvet += ans1 - ans2 + 1;
      for (int i = 1; i <= x; i++) {
        a[j] = (a[j] * 10) % k;
      }
      if (a[j] == poisk) {
        otvet--;
      }
    }
  }
  cout << otvet;
  return 0;
}
