#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[15];
int arr[200100];
int cnt[200100];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    int num = 0;
    int y = x;
    while (y) num++, y /= 10;
    x = x % k;
    arr[i] = x;
    mp[num][x]++;
    cnt[i] = num;
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long x = arr[i];
    mp[cnt[i]][x]--;
    for (int j = 1; j <= 10; ++j) {
      x *= 10;
      if (x >= k) x %= k;
      int need = (k - x);
      if (need == k) need = 0;
      if (mp[j].count(need)) ans += mp[j][need];
    }
    x = arr[i];
    mp[cnt[i]][x]++;
  }
  cout << ans << endl;
}
