#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int n, k, a[200000];
long long ans;
map<int, int> md[11];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    int cur = a[i] % k;
    for (int j = 0; j < 11; j++) ++md[j][cur], cur = ((long long)10 * cur) % k;
  }
  for (int i = 0; i < n; i++) {
    int tmp = a[i], numdig = 0;
    while (tmp != 0) tmp /= 10, ++numdig;
    long long tmp2 = a[i];
    for (int i = 0; i < numdig; i++) tmp2 = (tmp2 * 10) % k;
    if ((tmp2 + a[i]) % k == 0) --ans;
    ans += md[numdig][(k - a[i] % k) % k];
  }
  cout << ans << endl;
}
