#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const int maxn = 2e5 + 7;
int n, k;
int a[maxn];
unordered_map<int, long long> mp[15];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    long long x = a[i];
    for (int j = 1; j <= 10; j++) {
      x = (x * 10) % k;
      mp[j][x]++;
    }
  }
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    int len = log10(a[i]) + 1;
    ret += mp[len][(k - a[i] % k) % k];
    long long x = a[i];
    for (int j = 1; j <= len; j++) {
      x = (x * 10) % k;
    }
    if (x == (k - a[i] % k) % k) ret--;
  }
  cout << ret;
  return 0;
}
