#include <bits/stdc++.h>
using namespace std;
int p[200002];
int mul[11][200002];
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; i++) scanf("%d", &p[i]);
  for (int x = 1; x <= 10; x++) {
    long long v = 1;
    for (int i = 1; i <= x; i++) v *= 10;
    v %= K;
    for (int i = 1; i <= N; i++) mul[x][i] = p[i] * v % K;
  }
  for (int x = 1; x <= 10; x++) sort(mul[x] + 1, mul[x] + N + 1);
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    int d = 1;
    long long v = 10;
    while (p[i] >= v) {
      d++;
      v *= 10;
    }
    v %= K;
    int req = K - p[i] % K;
    if (req == K) req = 0;
    auto rs = lower_bound(mul[d] + 1, mul[d] + N + 1, req);
    auto re = upper_bound(mul[d] + 1, mul[d] + N + 1, req);
    int cnt = re - rs;
    if (p[i] * v % K == req) cnt--;
    ans += cnt;
  }
  printf("%lld\n", ans);
  return 0;
}
