#include <bits/stdc++.h>
using namespace std;
long long n, a[234567], pw[100], k;
long long ans;
map<int, int> re[14];
int flog(int x) {
  int cnt = 0;
  while (x) ++cnt, x /= 10;
  return cnt;
}
int main() {
  pw[0] = 1LL;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= 10; ++i) {
    pw[i] = pw[i - 1] * 10LL;
    pw[i] %= k;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    ans -= (a[i] * pw[flog(a[i])] + a[i]) % k == 0LL ? 1LL : 0LL;
    for (int j = 1; j <= 10; ++j) {
      ++re[j][a[i] * pw[j] % k];
    }
  }
  for (int i = 1; i <= n; ++i) {
    int fl = flog(a[i]), c = (k - a[i] % k) % k;
    if (re[fl].find(c) != re[fl].end()) ans += re[fl][c];
  }
  printf("%I64d", ans);
}
