#include <bits/stdc++.h>
using namespace std;
long long ans;
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x < y ? x : y; }
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
void write(int x) {
  int buf[50];
  if (x < 0) putchar('-'), x = -x;
  buf[0] = 0;
  while (x) buf[++buf[0]] = x % 10, x /= 10;
  if (!buf[0]) buf[0] = 1, buf[1] = 0;
  while (buf[0]) putchar('0' + buf[buf[0]--]);
}
int a[200200], wei[200200];
long long t[11];
map<int, long long> Map[11];
int main() {
  int n = read(), k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  t[0] = 1;
  for (int i = 1; i <= 10; i++) t[i] = t[i - 1] * 10;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++)
      if (a[i] < t[j]) {
        wei[i] = j;
        a[i] %= k;
        break;
      }
  for (int i = 1; i <= 10; i++) t[i] %= k;
  for (int i = 1; i <= 10; i++)
    for (int j = 1; j <= n; j++) Map[i][t[i] * a[j] % k]++;
  for (int i = 1; i <= n; i++) ans += Map[wei[i]][(k - a[i]) % k];
  for (int i = 1; i <= n; i++)
    if ((t[wei[i]] + 1ll) * a[i] % k == 0) ans--;
  cout << ans;
  return 0;
}
