#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
const long long MOD = 1e9 + 7;
int N, M, Q;
unordered_map<int, int> mp[11];
int A[MAX];
int main() {
  int i, j;
  int x, K;
  scanf("%d%d", &N, &K);
  for (i = 1; i <= 10; ++i) mp[i].reserve(MAX);
  for (i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    long long tens = 10;
    for (j = 1; j <= 10; ++j) {
      long long tmp = (long long)A[i] * tens % K;
      mp[j][tmp]++;
      tens = tens * 10LL % K;
    }
  }
  long long cnt = 0;
  for (i = 1; i <= N; ++i) {
    long long tmp = A[i];
    int digit = 0LL;
    while (tmp) {
      digit++;
      tmp /= 10LL;
    }
    long long q = A[i] % K;
    long long tens = 1LL;
    for (j = 1; j <= digit; ++j) {
      tens = tens * 10LL % K;
    }
    if (((long long)A[i] * tens % K + q) % K == 0) {
      cnt--;
    }
    cnt += (long long)mp[digit][((-q) + K) % K];
  }
  printf("%lld", cnt);
}
