Link to this code: https://cses.fi/paste/b08f4b497e0f58fc30e361/
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;

const int N = 2e5 + 5;

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
	cin >> n >> x;

	int a[N];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	ll sum = 0, ans = 0;
	int l = 0, r = 0;
	while (r < n) {
		sum += a[r];
		while (sum > x) {
			sum -= a[l];
			l++;
		}
		if (sum == x) {
			ans++;
		}
		r++;
	}

	cout << ans << '\n';
}