#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int INF = 2147483647;
const long double PI = 3.1415926535898;
const long long oo = 9223372036854775807;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
template <class T>
T getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
T cntbit(T s) {
  return __builtin_popcountt(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
T Max(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T Min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
long long pow(T a, T b) {
  long long res = 1;
  for (long long i = 1; i <= b; i++) res = res * a;
  return res;
}
template <class T>
void read(T &x) {
  x = 0;
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  x = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
}
template <class T>
void readchar(T &x) {
  for (x = getchar(); x != 'D' && x != 'C'; x = getchar())
    ;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename T>
inline void writec(T x) {
  write(x);
  putchar(' ');
}
int n, k;
long long ans = 0;
int b[2000000], c[11][2000000], dp[2000000];
map<int, int> cnt[11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    for (int j = a; j > 0; j /= 10) dp[i]++;
    c[0][i] = b[i] = a % k;
    for (long long j = 1; j <= 10; j++) {
      c[j][i] = c[j - 1][i] * 10LL % k;
      cnt[j][c[j][i]]++;
    }
  }
  for (long long i = 1; i <= n; i++) {
    ans += cnt[dp[i]][(k - b[i]) % k];
    if ((c[dp[i]][i] + b[i]) % k == 0) ans--;
  }
  cout << ans;
}
