#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int n, k;
int a[N];
vector<int> du[11];
int main() {
  long long ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    int j;
    for (j = 1; j <= 11; ++j)
      if (a[i] / ((long long)ceil(pow(10, j))) == 0) break;
    du[j].push_back(a[i] % k);
    long long t =
        (long long)1ll * (a[i] * ((long long)ceil(pow(10, j)) % k) % k) + a[i];
    if (t % k == 0) --ans;
  }
  for (int i = 1; i < 11; ++i) {
    sort(du[i].begin(), du[i].end());
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= 10; ++j) {
      long long fi = 1ll * (a[i] % k) * ((long long)ceil(pow(10, j)) % k) % k;
      ans += upper_bound(du[j].begin(), du[j].end(), (k - fi) % k) -
             lower_bound(du[j].begin(), du[j].end(), (k - fi) % k);
    }
  cout << ans;
}
