#include<iostream>
#include<string>
#include<deque>
using namespace std;
int a[1000001], n;
long long int ans = 0;
string s;
int k;
int bn_find_first_max_right(int l, int r, long long int x)
{
int vt = -1;
while (l <= r)
{
int mid = (l + r) / 2;
if (a[mid] == x)
{
vt = mid;
l = mid + 1;
}
else if (a[mid] > x)
r = mid - 1;
else if (a[mid] < x)
l = mid + 1;
}
return vt;
}
int bn_find_first_max_left(int l, int r, long long int x)
{
int vt = -1;
while (l <= r)
{
int mid = (l + r) / 2;
if (a[mid] == x)
{
vt = mid;
r = mid - 1;
}
else if (a[mid] > x)
r = mid - 1;
else if (a[mid] < x)
l = mid + 1;
}
return vt;
}
void inp()
{
cin >> k;
cin.ignore();
getline(cin, s);
n = s.size();
s = 'x' + s;
for (int i = 1; i <= n; i++)
a[i] = a[i - 1] + (s[i] - '0');
}
void xuli()
{
for(int i = 1; i <= n; i++)
if (a[i] >= k)
{
int left = bn_find_first_max_left(0, i - 1, a[i] - k);
int right = bn_find_first_max_right(0, i - 1, a[i] - k);
if(left != - 1 && right != -1)
ans += right - left + 1;
}
cout << ans;
}
int main()
{
inp();
xuli();
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8ZGVxdWU+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGFbMTAwMDAwMV0sIG47CmxvbmcgbG9uZyBpbnQgYW5zID0gMDsKc3RyaW5nIHM7CmludCBrOwoKaW50IGJuX2ZpbmRfZmlyc3RfbWF4X3JpZ2h0KGludCBsLCBpbnQgciwgbG9uZyBsb25nIGludCB4KQp7CglpbnQgdnQgPSAtMTsKCXdoaWxlIChsIDw9IHIpCgl7CgkJaW50IG1pZCA9IChsICsgcikgLyAyOwoJCWlmIChhW21pZF0gPT0geCkKCQl7CgkJCXZ0ID0gbWlkOwoJCQlsID0gbWlkICsgMTsKCQl9CgkJZWxzZSBpZiAoYVttaWRdID4geCkKCQkJciA9IG1pZCAtIDE7CgkJZWx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