#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[11];
int ara[200005], length[200005];
int find_len(int n) {
  int len = 0;
  while (n) {
    len++;
    n /= 10;
  }
  return len;
}
int main() {
  int n, k, i, j;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%d", &ara[i]);
    int len = find_len(ara[i]);
    mp[len][ara[i] % k]++;
    length[i] = len;
  }
  long long int ans = 0;
  for (i = 1; i <= n; i++) {
    unsigned long long int cur = 10;
    int num = ara[i] % k, len = 1;
    while (cur <= 1e10) {
      unsigned long long int val = num * cur;
      unsigned long long int rem = k - (val % k);
      if (rem == k) rem = 0;
      if (mp[len].count(rem)) ans += (long long int)mp[len][rem];
      if (length[i] == len && rem == num) {
        ans--;
      }
      len++;
      cur *= 10;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
