//code pfs
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 7;
string s;
ll n, k, ans;

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    //freopen("input.inp", "r", stdin);freopen("output.out", "w", stdout);
    cin >> k >> s;
    n = s.size();
    s = ' ' + s;  
    vector<ll> freq(n + 1, 0);
    freq[0] = 1;
    ll p = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1') p++;
        if (p >= k) ans += freq[p - k];
        freq[p]++;
    }
    cout << ans;

}