#include <bits/stdc++.h>
using namespace std;
int digits(int n) {
  int count = 0;
  while (n != 0) {
    count++;
    n /= 10;
  }
  return count;
}
int32_t main() {
  long long int power[11];
  int n, k;
  scanf("%d%d", &n, &k);
  map<int, int> mp[11];
  int i, j;
  power[0] = 1;
  for (j = 1; j <= 10; j++) {
    long long int x = 10 * power[j - 1];
    x %= k;
    power[j] = x;
  }
  int arr[n];
  long long int count[n];
  for (j = 0; j < n; j++) {
    scanf("%d", &arr[j]);
    int d = digits(arr[j]);
    count[j] = d;
    mp[d][arr[j] % k]++;
  }
  long long int answer = 0;
  for (j = 0; j < n; j++) {
    long long int val = arr[j];
    for (i = 1; i <= 10; i++) {
      long long int here = val * power[i];
      here %= k;
      answer += mp[i][(k - here) % k];
    }
  }
  for (j = 0; j < n; j++) {
    long long int val = arr[j];
    long long int d = count[j];
    val *= power[d];
    val += arr[j];
    if (val % k == 0) answer--;
  }
  printf("%lld\n", answer);
}
