#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  int n, m, i, j, sum, count1 = 0;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    sum = 0;
    for (j = 1; j <= i; j++) {
      sum += j;
    }
    if (sum % m == 0) count1++;
  }
  printf("%d", count1);
  return 0;
}
