#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(void){
    int n,m; cin>>n>>m;
    vector <int> a(n);
    vector <ll> nums(n+10);
    for(int i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    ll ans = 0;
    for(int r=0;r<n;r++){
        int cnt =0 ;
        for(int l=r;l>=0;l--){
            cnt += a[l];
            if(cnt!=0&&cnt%m==0) {ans = nums[r+1] = nums[l] + 1;  break;}
        }
    }
    cout<<ans<<endl;
}
