#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long n, k, ans, pw[11], a[200005];
map<int, int> w[11];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(30);
  cerr.precision(7);
  ;
  cin >> n >> k;
  pw[0] = 1LL;
  for (int i = 1; i <= 10; i++) pw[i] = (pw[i - 1] * 10LL) % k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 1; j <= 10; j++) w[j][(a[i] * pw[j]) % k]++;
  }
  for (int i = 1; i <= n; i++) {
    int l = (int)to_string(a[i]).size();
    ans += w[l][(k - (a[i] % k)) % k];
    ans -= !(((pw[l] * a[i]) % k + a[i]) % k);
  }
  cout << ans;
  return 0;
}
