#include <bits/stdc++.h>
using namespace std;
int a[1000005];
unordered_map<long long, long long> mp1[12];
long long mp2[13];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    long long x = a[i];
    for (int j = 1; j <= 10; j++) {
      mp1[j][(1ll * x % m * 10) % m]++;
      x = (1ll * x % m * 10) % m;
    }
  }
  mp2[0] = 1;
  for (int i = 1; i <= 10; i++) {
    mp2[i] = mp2[i - 1] * 10;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long x = a[i];
    long long num = to_string(a[i]).length();
    x = a[i];
    long long st = m - (x % m);
    if (st == m) {
      ans += mp1[num][1ll * (x % m)] - 1;
    } else {
      ans += mp1[num][st];
      x = (x % m * mp2[num] % m) % m;
      if (x % m == st) ans--;
    }
  }
  cout << ans;
}
