#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long a[100005];
long long sum[100005];
map<long long, long long> mp;
signed main() {
  long long n, m;
  cin >> n >> m;
  mp[0] = 1;
  sum[0] = 0;
  long long ret = 0;
  for (long long i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
    ret += mp[sum[i] % m];
    mp[sum[i] % m]++;
  }
  cout << ret << endl;
}
