#include <bits/stdc++.h>
using namespace std;
long long cont[200005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  while (cin >> n >> m) {
    map<long long, long long> mp[15];
    for (int i = 0; i < n; i++) {
      long long add;
      cin >> add;
      cont[i] = add;
      for (int i = 1; i < 10 + 1; i++) {
        add *= 10;
        add %= m;
        mp[i][add]++;
      }
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      long long need = (m - cont[i] % m) % m;
      int cnt = 0;
      long long num = cont[i];
      while (num) {
        num /= 10;
        cnt++;
      }
      num = cont[i];
      for (int i = 0; i < cnt; i++) {
        num *= 10;
        num %= m;
      }
      if (num == need) {
        if (mp[cnt].find(need) != mp[cnt].end()) ans += mp[cnt][need] - 1;
      } else {
        if (mp[cnt].find(need) != mp[cnt].end()) ans += mp[cnt][need];
      }
    }
    cout << ans << endl;
  }
}
