#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(long double a, long double b) {
  return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }
void M() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
int arr[200009], v[200009][12];
map<pair<int, int>, int> v2;
long long ten[20];
int getlen(int n) {
  int cnt = 0;
  while (n) {
    n /= 10;
    cnt++;
  }
  return cnt;
}
long long mod(long long n, long long k) { return n - ((n / k) * k); }
int main() {
  M();
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    int l = getlen(arr[i]);
    v2[make_pair(l, mod(arr[i], k))]++;
  }
  ten[0] = 1;
  for (int i = 1; i <= 10; i++) ten[i] = ten[i - 1] * 10;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      v[i][j] = mod((mod(arr[i], k) * mod(ten[j], k)), k);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      int a = k - v[i][j];
      int b = v2[make_pair(j, a)];
      ans += b;
      if (v[i][j] == 0) {
        ans += v2[make_pair(j, 0)];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int num = mod(
        mod(mod(arr[i], k) * mod(ten[getlen(arr[i])], k), k) + mod(arr[i], k),
        k);
    if (num == 0) ans--;
  }
  cout << ans << endl;
}
