#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
int n, k;
int a[maxn + 5];
map<int, int> mp[15];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    long long x = a[i];
    for (int j = 1; j <= 10; j++) {
      x *= 10;
      x %= k;
      mp[j][x]++;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int len = log10(a[i]) + 1;
    ans += mp[len][(k - a[i] % k) % k];
    long long x = 1;
    for (int j = 1; j <= len; j++) x = x * 10 % k;
    if (((x * a[i]) % k + a[i] % k) % k == 0) ans--;
  }
  cout << ans << endl;
  return 0;
}
