#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[11];
const int N = 2e5 + 5;
int ws(int u) { return (int)log10(u) + 1; }
int n, k, a[N], mo[11][N];
long long ans;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mo[0][i] = a[i] % k;
    for (int j = 1; j <= 10; j++) {
      mo[j][i] = (int)(((long long)mo[j - 1][i] * 10) % k);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      if (mo[j][i]) {
        mp[j][mo[j][i]]++;
      } else {
        mp[j][0]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int w = ws(a[i]);
    if (mo[0][i]) {
      ans += mp[w][k - mo[0][i]];
    } else {
      ans += mp[w][0];
    }
    if ((mo[w][i] + mo[0][i]) % k == 0) {
      ans--;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
