//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;
}
Ly9jb2RlIHBmcwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CmNvbnN0IGludCBNQVhOID0gMWU1ICsgNzsKc3RyaW5nIHM7CmxsIG4sIGssIGFuczsKCmludCBtYWluKCkgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNvdXQudGllKDApOwogICAgY2luLnRpZSgwKTsKICAgIC8vZnJlb3BlbigiaW5wdXQuaW5wIiwgInIiLCBzdGRpbik7ZnJlb3Blbigib3V0cHV0Lm91dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIGNpbiA+PiBrID4+IHM7CiAgICBuID0gcy5zaXplKCk7CiAgICBzID0gJyAnICsgczsgIAogICAgdmVjdG9yPGxsPiBmcmVxKG4gKyAxLCAwKTsKICAgIGZyZXFbMF0gPSAxOwogICAgbGwgcCA9IDA7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICBpZiAoc1tpXSA9PSAnMScpIHArKzsKICAgICAgICBpZiAocCA+PSBrKSBhbnMgKz0gZnJlcVtwIC0ga107CiAgICAgICAgZnJlcVtwXSsrOwogICAgfQogICAgY291dCA8PCBhbnM7Cgp9