#include <bits/stdc++.h>
using namespace std;
int n, k;
int df(int x) {
  int cnt = 1;
  x /= 10;
  while (x) {
    x /= 10;
    cnt++;
  }
  return cnt;
}
long long int f(int arr[]) {
  map<int, map<int, int>> m;
  int x, d;
  int mod;
  for (int i = 0; i < n; i++) {
    x = arr[i];
    mod = x % k;
    d = df(x);
    m[d][mod]++;
  }
  long long int r, t, dx, fr;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    x = arr[i];
    dx = df(x);
    long long int mul = 10;
    for (long long int d = 1; d <= 10; d++) {
      t = (x * (mul % k)) % k;
      mod = (k - t) % k;
      fr = 0;
      if (m.find(d) != m.end()) {
        if (m[d].find(mod) != m[d].end()) {
          fr = m[d][mod];
        }
      }
      if (dx == d) {
        if (x % k == mod) {
          fr--;
        }
      }
      ans += fr;
      mul *= 10;
    }
  }
  return ans;
}
int main() {
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cout << f(arr) << endl;
  return 0;
}
