#include <bits/stdc++.h>

using namespace std;

vector < long long > v;

int main() {
    string s;
    long long res = 0, k;
    cin >> k;
    cin >> s;
    for(int i = 0; i < s.size();  i ++)
        if(s[i] == '1')v.push_back(i + 1);
    if(k == 0) {
        if(v.empty()) {
            res = s.size() * (s.size() + 1) / 2;
            cout << res;
            return 0;
        }
        for(int i = 0 ; i < v.size(); i ++) {
            if(i > 0){res += ((v[i] - v[i - 1] - 1) * (v[i] - v[i - 1] )) / 2;}
            else res += (v[0] * (v[0] - 1)) / 2;
        }
        long long m = s.size() - v[v.size() - 1];
        res += ((m) * (m + 1)) / 2;
        cout <<res;
        return 0;
    }
    if(v.size() < k) {
        cout << 0;
        return 0;
    }
    if(v.size() == k) {
        cout << (s.size() - v[k - 1] + 1) * v[0];
        return 0;
    }
    res = v[0] * (v[k] - v[k -1]);
    for(int i = k + 1; i < v.size(); i ++) {
        res += (v[i - k] - v[i - k - 1]) * (v[i] - v[i - 1]);
    }
    res += (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> vec;

int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int k; string s; cin >> k >> s;
	s.push_back('1');
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') vec.push_back(i);
	}
	if (vec.size() < k + 1) return cout << 0 << endl, 0;
	long long ans = 1ll * (vec[0] + 1) * (vec[k] - vec[k - 1]);
	for (int i = 1; i < vec.size() - k; i++) {
		ans += 1ll * (vec[i] - vec[i - 1]) * (vec[i + k] - vec[i + k - 1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector < int > v;

int main() {
	string s;
	int res, k;
	cin >> k;
	cin >> s;
	for(int i = 0; i < s.size();  i ++)
		if(s[i] == '1')v.push_back(i + 1);
	if(v.size() < k){cout << 0; return 0;}
	if(v.size() == k){
		cout << (s.size() - v[k - 1] + 1) * v[0];
		return 0;
	}
	res = v[0] * (v[k] - v[k -1]);
	for(int i = k; i < v.size() - 1; i ++){
		res += (v[i - k + 1] - v[i - k ]) * (v[i] - v[i - 1]);
	}
	res += (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
	cout << res;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

vector < long long > v;

int main() {
    string s;
    long long res = 0, k;
    cin >> k;
    cin >> s;
    for(int i = 0; i < s.size();  i ++)
        if(s[i] == '1')v.push_back(i + 1);
    if(k == 0) {
        if(v.empty()) {
            res = 1ll * s.size() * (s.size() + 1) / 2;
            cout << res;
            return 0;
        }
        for(int i = 0 ; i < v.size(); i ++) {
            if(i > 0){res += 1ll * ((v[i] - v[i - 1] - 1) * (v[i] - v[i - 1] )) / 2;}
            else res += 1ll * (v[0] * (v[0] - 1)) / 2;
        }
        long long m = s.size() - v[v.size() - 1];
        res += 1ll * ((m) * (m + 1)) / 2;
        cout <<res;
        return 0;
    }
    if(v.size() < k) {
        cout << 0;
        return 0;
    }
    if(v.size() == k) {
        res = 1ll * (s.size() - v[k - 1] + 1) * v[0];
        cout << res;
        return 0;
    }
    res = 1ll * v[0] * (v[k] - v[k -1]);
    for(int i = k + 1; i < v.size(); i ++) {
        res += 1ll * (v[i - k] - v[i - k - 1]) * (v[i] - v[i - 1]);
    }
    res += 1ll * (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
    cout << res;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1000010
typedef long long ll;
char s[N];
vector<int> v;
int main(){
    int k;
    scanf("%d", &k);
    scanf("%s", s);
    ll ans = 0;
    int len = strlen(s);
    for(int i = 0; i < len; i ++){
        if(s[i] == '1') v.push_back(i);
    }
    if(k == 0){
        int l = 0;
        int r = v[0];
        ans += 1ll * (r - l) * (r - l + 1) / 2;
        for(int i = 1; i < v.size(); i ++){
            l = v[i - 1];
            r = v[i];
            ans += 1ll * (r - l) * (r - l - 1) / 2;
        }
        l = v[v.size() - 1];
        r = len - 1;
        ans += 1ll * (r - l) * (r - l + 1) / 2;
        cout << ans;
        return 0;
    }
    for(int i = 0; i < v.size(); i ++){
        int st = i;
        int en = i + k - 1;
        if(en >= v.size()) break;
        int l , r;
        if(st == 0) l = v[st] - 0;
        else l = v[st] - v[st - 1] - 1;
        if(en == v.size() - 1) r = len - 1 -  v[en];
        else r = v[en + 1] - v[en] - 1;
        ans += 1ll * (l + 1) * (r + 1);
    }
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> vec;

int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int k; string s; cin >> k >> s;
	s.push_back('1');
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') vec.push_back(i);
	}
	if (!k) {
		if (s.size() == 2) return cout << 1 << endl, 0;
		long long ans = vec[0] + 1;
		for (int i = 1; i < vec.size(); i++) {
			ans *= vec[i] - vec[i - 1];
		}
		cout << ans << endl;
	} else {
		if (vec.size() < k + 1) return cout << 0 << endl, 0;
		long long ans = 1ll * (vec[0] + 1) * (vec[k] - vec[k - 1]);
		for (int i = 1; i < vec.size() - k; i++) {
			ans += 1ll * (vec[i] - vec[i - 1]) * (vec[i + k] - vec[i + k - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector < long long > v;

int main() {
	string s;
	long long res, k;
	cin >> k;
	cin >> s;
	for(int i = 0; i < s.size();  i ++)
		if(s[i] == '1')v.push_back(i + 1);
	if(v.size() < k){cout << 0; return 0;}
	if(v.size() == k){
		cout << (s.size() - v[k - 1] + 1) * v[0];
		return 0;
	}
	res = v[0] * (v[k] - v[k -1]);
	for(int i = k + 1; i < v.size(); i ++){
		res += (v[i - k] - v[i - k - 1]) * (v[i] - v[i - 1]);
	}
	res += (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
	cout << res;
}


#include <bits/stdc++.h>

using namespace std;

vector < long long > v;

int main() {
	string s;
	long long res = 0, k;
	cin >> k;
	cin >> s;
	for(int i = 0; i < s.size();  i ++)
		if(s[i] == '1')v.push_back(i + 1);
	if(k == 0){
		if(v.empty()){cout << s.size() * (s.size() + 1) / 2;return 0;}
		for(int i = 0 ; i < v.size(); i ++){
			if(i > 0)res += ((v[i] - v[i - 1]) * (v[i] - v[i - 1] +1)) / 2;
			else res += (v[0] * (v[0] - 1)) / 2;
		}
		int m = s.size() - v[v.size() - 1];
		res += (m * (m + 1)) / 2;
		cout <<res;
		return 0;
	}
	if(v.size() < k){cout << 0; return 0;}
	if(v.size() == k){
		cout << (s.size() - v[k - 1] + 1) * v[0];
		return 0;
	}
	res = v[0] * (v[k] - v[k -1]);
	for(int i = k + 1; i < v.size(); i ++){
		res += (v[i - k] - v[i - k - 1]) * (v[i] - v[i - 1]);
	}
	res += (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
	cout << res;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1000010
typedef long long ll;
char s[N];
vector<int> v;
int main(){
    int k;
    scanf("%d", &k);
    scanf("%s", s);
    ll ans = 0;
    int len = strlen(s);
    for(int i = 0; i < len; i ++){
        if(s[i] == '1') v.push_back(i);
    }
    if(k == 0){
        if(v.size() == 0) {ans += 1ll * len * (len + 1) / 2; cout << ans; return 0;}
        int l = 0;
        int r = v[0];
        ans += 1ll * (r - l) * (r - l + 1) / 2;
        for(int i = 1; i < v.size(); i ++){
            l = v[i - 1];
            r = v[i];
            ans += 1ll * (r - l) * (r - l - 1) / 2;
        }
        l = v[v.size() - 1];
        r = len - 1;
        ans += 1ll * (r - l) * (r - l + 1) / 2;
        cout << ans;
        return 0;
    }
    for(int i = 0; i < v.size(); i ++){
        int st = i;
        int en = i + k - 1;
        if(en >= v.size()) break;
        int l , r;
        if(st == 0) l = v[st] - 0;
        else l = v[st] - v[st - 1] - 1;
        if(en == v.size() - 1) r = len - 1 -  v[en];
        else r = v[en + 1] - v[en] - 1;
        ans += 1ll * (l + 1) * (r + 1);
    }
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> vec;

int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int k; string s; cin >> k >> s;
	s.push_back('1');
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') vec.push_back(i);
	}
	if (vec.size() < k + 1) return cout << 0 << endl, 0;
	int ans = (vec[0] + 1) * (vec[k] - vec[k - 1]);
	for (int i = 1; i < vec.size() - k; i++) {
		ans += (vec[i] - vec[i - 1]) * (vec[i + k] - vec[i + k - 1]);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector < long long > v;

int main() {
    string s;
    long long res = 0, k;
    cin >> k;
    cin >> s;
    for(int i = 0; i < s.size();  i ++)
        if(s[i] == '1')v.push_back(i + 1);
    if(k == 0) {
        if(v.empty()) {
            cout << s.size() * (s.size() + 1) / 2;
            return 0;
        }
        for(int i = 0 ; i < v.size(); i ++) {
            if(i > 0){res += ((v[i] - v[i - 1] - 1) * (v[i] - v[i - 1] )) / 2;}
            else res += (v[0] * (v[0] - 1)) / 2;
        }
        int m = s.size() - v[v.size() - 1];
        res += ((m) * (m + 1)) / 2;
        cout <<res;
        return 0;
    }
    if(v.size() < k) {
        cout << 0;
        return 0;
    }
    if(v.size() == k) {
        cout << (s.size() - v[k - 1] + 1) * v[0];
        return 0;
    }
    res = v[0] * (v[k] - v[k -1]);
    for(int i = k + 1; i < v.size(); i ++) {
        res += (v[i - k] - v[i - k - 1]) * (v[i] - v[i - 1]);
    }
    res += (s.size() - v[v.size() - 1] + 1) * (v[v.size() - k] - v[v.size() - k - 1]);
    cout << res;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1000010
typedef long long ll;
char s[N];
vector<int> v;
int main(){
    int k;
    scanf("%d", &k);
    scanf("%s", s);
    int len = strlen(s);
    for(int i = 0; i < len; i ++){
        if(s[i] == '1') v.push_back(i);
    }
    ll ans = 0;
    for(int i = 0; i < v.size(); i ++){
        int st = i;
        int en = i + k - 1;
        if(en >= v.size()) break;
        int l ,r;
        if(st == 0) l = v[st] - 0;
        else l = v[st] - v[st - 1] - 1;
        if(en == v.size() - 1) r = len - 1 -  v[en];
        else r = v[en + 1] - v[en] - 1;
        ans += 1ll * (l + 1) * (r + 1);
    }
    cout << ans;
}


    #include <bits/stdc++.h>

using namespace std;
const long long INF = 1e9 + 10;

long long n, k;

long long check(long long M) {
    long long s = 0 ,t = 1;
    while(M / t != 0) {
        s += M / t;
        t *= k;
    }
    if(s > n)return 1;
    else if(s == n)return 0;
    else if(s < n)return -1;
}
int main() {
    long long L = 0, R = INF, M, t;
    cin >> n >> k;
    while(R > L + 1) {
        M = (R + L) / 2;
        t = check(M);
        if(t == 1)R = M;
        else if(t == -1)L = M;
        else if(t == 0) {
            cout << M;
            return 0;
        }
    }
    for(int i = L - 3 ; i <= n; i ++) {
        if(check(i)!= -1) {
            cout << i;
            return 0;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 10;
string s;
int a[N];
long long res = 0;

int main(){
	int n;
	cin >> n;
	cin >> s;
	int id = 0;
	int len = s.size();
	for(int i = 0; i < len; i++)
		if(s[i] - '0' == 1) { a[id] = i; id++; }
	a[id] = len;
	if(id < n) {return cout << 0 <<endl, 0;}
	for(int i = n - 1; i <= id - 1; i++){
		int p;
		if(i - n < 0) p = -1;
		else p = a[i - n];
		res += (a[i + 1] - a[i]) * (a[i - n + 1] - p);
	}
	cout << res <<endl;
}


#include <bits/stdc++.h>
#include <iostream>

using namespace std;
typedef long long int ll;

int main()
{
    ll k;
    std::cin >> k;
    string str;
    std::cin >> str;

    std::vector<int> pos;

    if(!k)
    {
        ll ans = 0;

        ll zero=0;

        for(int i=0;i<str.size();i++)
        {
            if(str[i]=='0')
            {
                zero++;
            }
            else
            {
                ans += 1ll*(zero+1)*zero/2;
                zero=0;
            }
        }
        ans += (zero+1)*zero/2;
        std::cout << ans << std::endl;
        return 0;
    }

    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='1')
        {
            pos.push_back(i+1);
        }
    }

    if(pos.size()<k)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    int ans=0;

    for(int i=0;i<pos.size();i++)
    {
        if(i+k>pos.size())break;
        int left = pos[i], right = pos[i+k-1];

        // std::cout << left<<" "<<right << "\t";

        int left_count , right_count ;

        if(i==0)
        {
            left_count = left - 1;
        }
        else
        {
            left_count = left - pos[i-1] - 1;
        }

        if(i+k ==pos.size())
        {
            right_count = str.size()-right;
        }
        else
        {
            right_count = pos[i+k] - right - 1;
        }

        // std::cout << left_count <<" "<<right_count << std::endl;

        ans += (left_count + right_count + left_count*right_count + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>

using namespace std;
typedef long long int ll;

int main()
{
    ll k;
    std::cin >> k;
    string str;
    std::cin >> str;

    std::vector<int> pos;

    if(!k)
    {
        int ans = 0;

        int zero=0;

        for(int i=0;i<str.size();i++)
        {
            if(str[i]=='0')
            {
                zero++;
            }
            else
            {
                ans += (zero+1)*zero/2;
                zero=0;
            }
        }
        ans += (zero+1)*zero/2;
        std::cout << ans << std::endl;
        return 0;
    }

    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='1')
        {
            pos.push_back(i+1);
        }
    }

    if(pos.size()<k)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    int ans=0;

    for(int i=0;i<pos.size();i++)
    {
        if(i+k>pos.size())break;
        int left = pos[i], right = pos[i+k-1];

        // std::cout << left<<" "<<right << "\t";

        int left_count , right_count ;

        if(i==0)
        {
            left_count = left - 1;
        }
        else
        {
            left_count = left - pos[i-1] - 1;
        }

        if(i+k ==pos.size())
        {
            right_count = str.size()-right;
        }
        else
        {
            right_count = pos[i+k] - right - 1;
        }

        // std::cout << left_count <<" "<<right_count << std::endl;

        ans += (left_count + right_count + left_count*right_count + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>

using namespace std;
typedef long long int ll;

int main()
{
    ll k;
    std::cin >> k;
    string str;
    std::cin >> str;

    std::vector<int> pos;

    if(!k)
    {
        ll ans = 0;

        ll zero=0;

        for(int i=0;i<str.size();i++)
        {
            if(str[i]=='0')
            {
                zero++;
            }
            else
            {
                ans += 1ll*(zero+1)*zero/2;
                zero=0;
            }
        }
        ans += (zero+1)*zero/2;
        std::cout << ans << std::endl;
        return 0;
    }

    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='1')
        {
            pos.push_back(i+1);
        }
    }

    if(pos.size()<k)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    ll ans=0;

    for(int i=0;i<pos.size();i++)
    {
        if(i+k>pos.size())break;
        ll left = pos[i], right = pos[i+k-1];

        // std::cout << left<<" "<<right << "\t";

        ll left_count , right_count ;

        if(i==0)
        {
            left_count = left - 1;
        }
        else
        {
            left_count = left - pos[i-1] - 1;
        }

        if(i+k ==pos.size())
        {
            right_count = str.size()-right;
        }
        else
        {
            right_count = pos[i+k] - right - 1;
        }

        // std::cout << left_count <<" "<<right_count << std::endl;

        ans += (left_count + right_count + 1ll*left_count*right_count + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>

using namespace std;
typedef long long int ll;

int main()
{
    ll k;
    std::cin >> k;
    string str;
    std::cin >> str;

    std::vector<int> pos;

    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='1')
        {
            pos.push_back(i+1);
        }
    }

    if(pos.size()<k)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    int ans=0;
    for(int i=0;i<pos.size();i++)
    {
        if(i+k>pos.size())break;
        int left = pos[i], right = pos[i+k-1];

        // std::cout << left<<" "<<right << "\t";

        int left_count , right_count ;

        if(i==0)
        {
            left_count = left - 1;
        }
        else
        {
            left_count = left - pos[i-1] - 1;
        }

        if(i+k ==pos.size())
        {
            right_count = str.size()-right;
        }
        else
        {
            right_count = pos[i+k] - right - 1;
        }

        // std::cout << left_count <<" "<<right_count << std::endl;

        ans += (left_count + right_count + left_count*right_count + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>

using namespace std;
typedef long long int ll;

int main()
{
    ll k;
    std::cin >> k;
    string str;
    std::cin >> str;

    std::vector<int> pos;

    if(!k)
    {
        ll ans = 0;

        ll zero=0;

        for(int i=0;i<str.size();i++)
        {
            if(str[i]=='0')
            {
                zero++;
            }
            else
            {
                ans += 1ll*(zero+1)*zero/2;
                zero=0;
            }
        }
        ans += (zero+1)*zero/2;
        std::cout << ans << std::endl;
        return 0;
    }

    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='1')
        {
            pos.push_back(i+1);
        }
    }

    if(pos.size()<k)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    ll ans=0;

    for(int i=0;i<pos.size();i++)
    {
        if(i+k>pos.size())break;
        int left = pos[i], right = pos[i+k-1];

        // std::cout << left<<" "<<right << "\t";

        int left_count , right_count ;

        if(i==0)
        {
            left_count = left - 1;
        }
        else
        {
            left_count = left - pos[i-1] - 1;
        }

        if(i+k ==pos.size())
        {
            right_count = str.size()-right;
        }
        else
        {
            right_count = pos[i+k] - right - 1;
        }

        // std::cout << left_count <<" "<<right_count << std::endl;

        ans += (left_count + right_count + left_count*right_count + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>
#include <iostream>

using namespace std;
typedef long long int ll;

int main()
{
    ll k;
    std::cin >> k;
    string str;
    std::cin >> str;

    std::vector<int> pos;

    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='1')
        {
            pos.push_back(i+1);
        }
    }

    if(!k)
    {
        std::cout << str.size() - pos.size() << std::endl;
        return 0;
    }

    if(pos.size()<k)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    int ans=0;

    for(int i=0;i<pos.size();i++)
    {
        if(i+k>pos.size())break;
        int left = pos[i], right = pos[i+k-1];

        // std::cout << left<<" "<<right << "\t";

        int left_count , right_count ;

        if(i==0)
        {
            left_count = left - 1;
        }
        else
        {
            left_count = left - pos[i-1] - 1;
        }

        if(i+k ==pos.size())
        {
            right_count = str.size()-right;
        }
        else
        {
            right_count = pos[i+k] - right - 1;
        }

        // std::cout << left_count <<" "<<right_count << std::endl;

        ans += (left_count + right_count + left_count*right_count + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
        int k;
        cin>>k;
        string s;
        int ans=0;
        int l=0;
        cin>>s;
        int n=s.length();

        for (int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                if(s[j]=='1')l++;
                if(l==k)ans++;}
                l=0;}
                cout<<ans;
     return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
          int b[1000000];
        int k;
        int j=0;
        cin>>k;
        string s;
        int ans=0;
        int l=0;
        cin>>s;
        int n=s.length();
        for(int i=0;i<n;i++){
        if(s[i]=='1') j++;
        if(j>=k) ans+=b[j-k];
        b[j]++;
            }
cout<<ans;
     return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
        long long int b[1000000];b[0]=1;
        long long int k,j=0;

        cin>>k;
        string s;
        int ans=0;

        cin>>s;
        int n=s.length();
        for(int i=0;i<n;i++){
        if(s[i]=='1') j++;
        if(j>=k) ans+=b[j-k];
        b[j]++;
            }
cout<<ans;
     return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
          int b[1000000];b[0]=1;
        int k;
        int j=0;
        cin>>k;
        string s;
        int ans=0;
        int l=0;
        cin>>s;
        int n=s.length();
        for(int i=0;i<n;i++){
        if(s[i]=='1') j++;
        if(j>=k) ans+=b[j-k];
        b[j]++;
            }
cout<<ans;
     return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
        int k;
        cin>>k;
        string s;
        int ans=0;
        int l=0;
        cin>>s;
        int n=s.length();
        if(k==0){cout<<0;return 0;}
        for (int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                if(s[j]=='1')l++;
                if(l==k)ans++;}

                l=0;}
                cout<<ans;
     return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
        long long int b[1000000];b[0]=1;
        long long int k,j=0;

        cin>>k;
        string s;
          long long int ans=0;

        cin>>s;
        int n=s.length();
        for(int i=0;i<n;i++){
        if(s[i]=='1') j++;
        if(j>=k) ans+=b[j-k];
        b[j]++;
            }
cout<<ans;
     return 0;
}


#include <bits/stdc++.h>

using namespace std;
int ar1[200000];
int ar2[200000];
  int a[200000];
pair<int ,int >p[200000];
string str[110];

      bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);

        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main() {
        long long int b[1111111];b[0]=1;
        long long int k,j=0;

        cin>>k;
        string s;
          long long int ans=0;

        cin>>s;
        int n=s.length();
        for(int i=0;i<n;i++){
        if(s[i]=='1') j++;
        if(j>=k) ans+=b[j-k];
        b[j]++;
            }
cout<<ans;
     return 0;
}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 16;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);

      deque<int>dq;
      int sum =0;
      int cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            dq.push_back(s[i]-'0');
            if(sum > k ) {
                  while(sum > k&& dq.size()) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            if(sum == k && dq.size())cnt ++;
      }
      while(sum==k&& dq.size()){
            sum -= dq.front();
            dq.pop_front();
            cnt ++;

      }
      printf("%d\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);
      if(k==0){
            LL cnt =0;
            LL calc= 0;
            for(int i =0 ;s[i] ; i ++ ) {
                  if(s[i]=='1'){
                        calc += cnt * (cnt + 1) /2;
                        cnt= 0;

                  }
                  else cnt ++;
            }
            printf("%lld\n" , calc);
            return 0;
      }
      deque<int>dq;
      int sum =0;
      LL cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            if(sum > k ) {
                  while(sum > k&& dq.size()) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            dq.push_back(s[i]-'0');
            if(sum ==k && dq.size()) cnt ++;
      }
      while(dq.size() > 1 && sum == k ) {
            sum -= dq.front();
            cnt ++;
            if(sum < k  ) break;
            dq.pop_front();
      }
      printf("%lld\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);
      if(k==0){
            LL cnt =0;
            LL calc= 0;
            for(int i =0 ;s[i] ; i ++ ) {
                  if(s[i]=='1'){
                        calc += cnt * (cnt + 1) /2;
                        cnt= 0;

                  }
                  else cnt ++;
            }
            calc += (cnt *(cnt+1)/2);
            printf("%lld\n" , calc);
            return 0;
      }
      deque<int>dq;
      int sum =0;
      LL cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            if(sum > k ) {
                  while(sum > k&& dq.size()) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            dq.push_back(s[i]-'0');
            if(sum ==k && dq.size()) cnt ++;
      }
      while(dq.size() > 1 && sum == k ) {
            sum -= dq.front();
            cnt ++;
            if(sum < k  ) break;
            dq.pop_front();
      }
      printf("%lld\n",cnt);

}


/*

 *************************
 Id  : Matrix.code
 Task:
 Date:

 **************************

 */

#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define Long                    long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define forn(i,n)               for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define all(x)                  (x).begin(),(x).end()
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define INF                     1<<29
#define EPS                     1e-9
#define Fr                      first
#define Sc                      second
#define Sz                      size()
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define Di(n)                   int n;si(n)
#define Dii(a,b)                int a,b;si(a);si(b)
#define Diii(a,b,c)             int a,b,c;si(a);si(b);si(c)
#define Si(n)                   si(n)
#define Sii(a,b)                si(a);si(b)
#define Siii(a,b,c)             si(a);si(b);si(c)
#define min(a,b)                ((a)>(b) ? (b) : (a) )
#define max(a,b)                ((a)>(b) ? (a):(b))
/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
typedef vector<Long> vl;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
template<class T> inline void si(T &x){register int c = gc();x = 0;int neg = 0;for(;((c<48 | c>57) && c != '-');c = gc());
      if(c=='-') {neg=1;c=gc();}for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}if(neg) x=-x;}
Long bigmod(Long p,Long e,Long M){Long ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;} return ret;}
Long gcd(Long a,Long b){if(b==0)return a;return gcd(b,a%b);}
Long modinverse(Long a,Long M){return bigmod(a,M-2,M);}
void io(){freopen("/Users/MyMac/Desktop/in.txt","r",stdin);}

/*************************** END OF TEMPLATE ****************************/

const int N = 1e6+5;
int sum[N];
string s;
int main()
{

	Di(k);
	cin >> s;
	if(k==0) {
        Long cnt = 0 ,ans = 0;
        for(int i= 0;i<s.length(); i++) {
            if(s[i]=='0')  cnt ++;
            else {
                ans  += (cnt*(cnt+1))/2;
                cnt = 0;
            }
        }
        ans += cnt * (cnt+1)/2;
        printf("%lld\n",ans);
        return 0;
	}
	sum[0] = s[0]=='1';
	for(int i= 0;i< s.length() ; i ++) {
		sum[i]= sum [i-1] + (s[i]=='1');
	}
	Long ans = 0;
	int n = s.length();
	for(int i=0;i<s.length() ; i ++) {
		int b = sum[i];
		int up = b+k-(s[i]=='1');
		int r= upper_bound(sum+i, sum + n , up) - sum;
		int l =  lower_bound(sum+i,sum+n,up) - sum ;
		ans += (r-l);
		//printf("%d %d %d\n",up, l,r);

	}
	printf("%lld\n",ans);
	return 0;
}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);

      deque<int>dq;
      int sum =0;
      int cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            dq.push_back(s[i]-'0');
            if(sum > k ) {
                  while(sum > k) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            if(sum == k )cnt ++;
      }
      while(sum==k){
            sum -= dq.front();
            dq.pop_front();
            cnt ++;

      }
      printf("%d\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);

      deque<int>dq;
      int sum =0;
      int cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            dq.push_back(s[i]-'0');
            if(sum > k ) {
                  while(sum > k&& dq.size()) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            if(sum == k && dq.size())cnt ++;
      }
      while(sum== k&& dq.size() > 1){
            sum -= dq.front();
            dq.pop_front();
            cnt ++;

      }
      printf("%d\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);
      if(k==0){
            LL cnt =0;
            LL calc= 0;
            for(int i =0 ;s[i] ; i ++ ) {
                  if(s[i]=='1'){
                        calc += cnt * (cnt + 1) /2;
                        cnt= 0;

                  }
                  else cnt ++;
            }
            calc += (cnt *(cnt+1)/2);
            printf("%lld\n" , calc);
            return 0;
      }
      deque<int>dq;
      int sum =0;
      LL cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            if(sum > k ) {
                  while(sum > k&& dq.size()) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            dq.push_back(s[i]-'0');
            if(sum ==k && dq.size()) cnt ++;
      }
      while(dq.size() && sum == k ) {
            sum -= dq.front();
            if(sum==k) cnt ++;
            dq.pop_front();
      }
      while(dq.size() && dq.back() == 0) {
            cnt ++;
            dq.pop_back();
      }
      printf("%lld\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);

      deque<int>dq;
      int sum =0;
      int cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            dq.push_back(s[i]-'0');
            if(sum > k ) {
                  while(sum > k) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            if(sum == k )cnt ++;
      }
      while(sum==k&& dq.size()){
            sum -= dq.front();
            dq.pop_front();
            cnt ++;

      }
      printf("%d\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//
#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */

#define LL                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define ITR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define DI(n)                   int n;scanf("%d",&n)
#define DII(a,b)                int a,b;scanf("%d %d",&a,&b)
#define DIII(a,b,c)             int a,b,c;scanf("%d %d %d",&a,&b,&c)

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x){
	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}
template <class T> inline T bigmod(T p,T e,T M){
	LL ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/
const int N = 1e6+6;
char s[N];

int main()
{
      DI(k);
      scanf("%s" ,s);
      if(k==0){
            LL cnt =0;
            LL calc= 0;
            for(int i =0 ;s[i] ; i ++ ) {
                  if(s[i]=='1'){
                        calc += cnt * (cnt + 1) /2;
                        cnt= 0;

                  }
                  else cnt ++;
            }
            calc += (cnt *(cnt+1)/2);
            printf("%lld\n" , calc);
            return 0;
      }
      deque<int>dq;
      int sum =0;
      LL cnt = 0;
      for(int i = 0; s[i] ; i ++ ) {
            sum += s[i] - '0';
            if(sum > k ) {
                  while(sum > k&& dq.size()) {
                        sum -= dq.front();
                        dq.pop_front();
                  }
            }
            dq.push_back(s[i]-'0');
            if(sum ==k && dq.size()) cnt ++;
      }
      while(dq.size() > 1 && sum == k ) {
            sum -= dq.front();
            if(sum==k) cnt ++;
            dq.pop_front();
      }
      printf("%lld\n",cnt);

}


//
//  main.cpp
//  165C
//
//  Created by Repon Macbook on 5/25/15.
//  Copyright (c) 2015 MAC. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

/*------- Constants---- */
#define LMT                     35
#define ll                      long long
#define ull                     unsigned long long
#define mod                     1000000007
#define MEMSET_INF              63
#define MEM_VAL                 1061109567
#define FOR(i,n)                for( int i=0 ; i < n ; i++ )
#define mp(i,j)                 make_pair(i,j)
#define lop(i,a,b)              for( int i = (a) ; i < (b) ; i++)
#define pb(a)                   push_back((a))
#define gc                      getchar_unlocked
#define PI                      acos(-1.0)
#define inf                     1<<30
#define lc                      ((n)<<1)
#define rc                      ((n)<<1 |1)
#define debug(x)                cout << #x << " -> " << x << endl;

/*---- short Cuts ------- */
#define ms(ara_name,value) memset(ara_name,value,sizeof(ara_name))
typedef pair<int, int> ii;
typedef vector<int > vi ;
/*------ template functions ------ */
#ifndef getchar_unlocked
#define getchar_unlocked getchar
#endif
inline void sc(int &x)
{

	register int c = gc();
	x = 0;
	int neg = 0;
	for(;((c<48 | c>57) && c != '-');c = gc());
	if(c=='-') {neg=1;c=gc();}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(neg) x=-x;
}

template <class T> inline T bigmod(T p,T e,T M){
	ll ret = 1;
	for(; e > 0; e >>= 1){
		if(e & 1) ret = (ret * p) % M;
		p = (p * p) % M;
	} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/*************************** END OF TEMPLATE ****************************/

int prefix[LMT];
string s;
int bs1(int val)
{
      int low = 0, high = s.length() - 1 , mid , ans = -1;
      while(low <= high ) {
            mid = (low + high ) /2;
            if( prefix[mid] == val ) {
                  ans = mid;
                  high = mid - 1;
            }
            else if( prefix[mid] < val ) low = mid + 1;
            else high = mid - 1;

      }
      return ans;
}

int bs2 ( int val )
{
      int low = 0, high = s.length() - 1, mid , ans = -1;
      while(low <= high ) {
            mid = (low + high ) /2;
            if( prefix[mid] == val ) {
                  ans = mid;
                  low = mid + 1;
            }
            else if( prefix[mid] < val ) low = mid + 1;
            else high = mid - 1;

      }
      return ans;

}
int main()
{

	int k;

      cin >> k >> s;
      ll ans = 0;
      prefix[0] = s[0] =='1';

      for( int i = 1; s[i] ; i ++) {
            prefix[i] = (s[i] =='1') + prefix[i-1];
      }

      for( int i = 0 ; s[i] ; i ++) {
            if(prefix[i] >= k ){
                  int L = bs1 ( prefix[i] - k );
                  int R = bs2 ( prefix[i] - k + 1);
                  ans += R - L ;
            }

      }

      cout << ans << endl;
	return 0;
}


#include <iostream>
#include <map>
#define fo(N) for(int i=0;i<N;i++)
#define fi(N) for(int i=1;i<=N;i++)
using namespace std;
int k,cnt;
string s;
long long ans;
map<int,int> m;
int main()
{
    cin>>k>>s;
    m[0]=-1;
    fo(s.length())
    {
        if(s[i]=='1'){cnt++,m[cnt]=i;}
    }
    m[cnt+1]=s.length();
    map<int,int>::iterator it;
    //for(it = m.begin();it!=m.end();it++)cout<<it->first<<" "<<it->second<<endl;
    fi(cnt)
    {
        if(m.find(i+k)!=m.end())
        ans+=(m[i]-m[i-1])*(m[i+k]-m[i+k-1]);
        else break;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <map>
#define ll long long
#define fo(N) for(int i=0;i<N;i++)
#define fi(N) for(int i=1;i<=N;i++)
using namespace std;
string s;
ll ans,ans1,k,cnt,cnt1;
map<ll,ll> m;
int main()
{
    cin>>k>>s;
    m[0]=-1;
    fo(s.length())
    {
        if(s[i]=='1'){cnt++,m[cnt]=i,ans1+=(cnt1*(cnt1+1))/2,cnt1=0;}
        else
        {
            cnt1++;
        }
    }
    ans1+=(cnt1*(cnt1+1))/2;
    if(k==0)return cout<<ans1,0;
    m[cnt+1]=s.length();
    //map<ll,ll>::iterator it;
    //for(it = m.begin();it!=m.end();it++)cout<<it->first<<" "<<it->second<<endl;
    fi(cnt)
    {
        if(m.find(i+k)!=m.end())
        ans+=(m[i]-m[i-1])*(m[i+k]-m[i+k-1]);
        else break;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <map>
#define fo(N) for(int i=0;i<N;i++)
#define fi(N) for(int i=1;i<=N;i++)
using namespace std;
int k,cnt;
string s;
long long ans;
map<int,int> m;
int main()
{
    cin>>k>>s;
    m[0]=-1;
    fo(s.length())
    {
        if(s[i]=='1'){cnt++,m[cnt]=i;}
    }
    if(k==0)return cout<<s.length()-cnt,0;
    m[cnt+1]=s.length();
    map<int,int>::iterator it;
    //for(it = m.begin();it!=m.end();it++)cout<<it->first<<" "<<it->second<<endl;
    fi(cnt)
    {
        if(m.find(i+k)!=m.end())
        ans+=(m[i]-m[i-1])*(m[i+k]-m[i+k-1]);
        else break;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#define fo(N) for(int i=0;i<N;i++)
#define iOS ios::sync_with_stdio(0)
#define ll long long
using namespace std;
ll k,cnt,ans,b[1000001];
string s;
int main()
{
    iOS;
    b[0]=1;
    cin>>k>>s;
    fo(s.length()){
    if(s[i]=='1')cnt++;
    if(cnt>=k)ans+=b[cnt-k];
    b[cnt]++;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <map>
#define iOS ios::sync_with_stdio(0)
#define ll long long
#define fo(N) for(int i=0;i<N;i++)
#define fi(N) for(int i=1;i<=N;i++)
using namespace std;
string s;
ll ans,ans1,k,cnt,cnt1;
map<ll,ll> m;
int main()
{
    iOS;
    cin>>k>>s;
    m[0]=-1;
    fo(s.length())
    {
        if(s[i]=='1'){cnt++,m[cnt]=i,ans1+=(cnt1*(cnt1+1))/2,cnt1=0;}
        else
        {
            cnt1++;
        }
    }
    ans1+=(cnt1*(cnt1+1))/2;
    if(k==0)return cout<<ans1,0;
    m[cnt+1]=s.length();
    //map<ll,ll>::iterator it;
    //for(it = m.begin();it!=m.end();it++)cout<<it->first<<" "<<it->second<<endl;
    fi(cnt)
    {
        if(m.find(i+k)!=m.end())
        ans+=(m[i]-m[i-1])*(m[i+k]-m[i+k-1]);
        else break;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#define fo(N) for(int i=0;i<N;i++)
#define iOS ios::sync_with_stdio(0)
#define ll long long
using namespace std;
ll k,cnt,ans,b[1000001];
string s;
int main()
{
    iOS;
    cin>>k>>s;
    fo(s.length()){
    if(s[i]=='1')cnt++;
    b[cnt]++;
    if(cnt>=k)ans+=b[cnt-k];
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <map>
#define fo(N) for(int i=0;i<N;i++)
#define fi(N) for(int i=1;i<=N;i++)
using namespace std;
int k,cnt,cnt1;
string s;
long long ans,ans1;
map<int,int> m;
int main()
{
    cin>>k>>s;
    m[0]=-1;
    fo(s.length())
    {
        if(s[i]=='1'){cnt++,m[cnt]=i,ans1+=(cnt1*(cnt1+1))/2,cnt1=0;}
        else
        {
            cnt1++;
        }
    }
    ans1+=(cnt1*(cnt1+1))/2;
    if(k==0)return cout<<ans1,0;
    m[cnt+1]=s.length();
    map<int,int>::iterator it;
    //for(it = m.begin();it!=m.end();it++)cout<<it->first<<" "<<it->second<<endl;
    fi(cnt)
    {
        if(m.find(i+k)!=m.end())
        ans+=(m[i]-m[i-1])*(m[i+k]-m[i+k-1]);
        else break;
    }
    cout<<ans;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        int cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        if(k==0)
        {
            int cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(1LL*(cnt*(cnt+1))/2);cnt=0;
                }
            }
            if(cnt)ans+=(1LL*(cnt*(cnt+1))/2);
            cout<<ans<<endl;
            continue;
        }
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=1LL*(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        int cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=(LL)(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        vector<int>one;
        vector<int>zero;
        string s;
        cin>>s;
        LL ans=0;
        LL cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        for(int i=0;i<len;i++)
        {
            if(s[i]=='1')one.push_back(i);
            else zero.push_back(i);
        }
        if(k==0)
        {
            LL cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(1LL*(cnt*(cnt+1)))/2;cnt=0;
                }
            }
            if(cnt)ans+=(1LL*(cnt*(cnt+1)))/2;
            cout<<ans<<endl;
            continue;
        }
        int l=0,temp=0;
        for(int i=0; i<one.size(); i++)
        {
            temp++;
            if(temp==k)
            {
                LL a,b;
                if(l>0)a=one[l]-one[l-1]-1;
                else a=one[l];
                if(i+1<one.size())
                b=one[i+1]-one[i]-1;
                else b=len-one[i]-1;
                //cout<<a<<","<<b<<endl;
                ans+=(LL)(a+b+a*b+1);
                l++;temp--;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        LL cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        if(k==0)
        {
            LL cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(1LL*(cnt*(cnt+1)))/2;cnt=0;
                }
            }
            if(cnt)ans+=(1LL*(cnt*(cnt+1)))/2;
            cout<<ans<<endl;
            continue;
        }
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=1LL*(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        int cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        if(k==0)
        {
            int cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(LL)(cnt*(cnt+1))/2;cnt=0;
                }
            }
            if(cnt)ans+=(LL)(cnt*(cnt+1))/2;
            cout<<ans<<endl;
            continue;
        }
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=(LL)(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        LL cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        if(k==0)
        {
            int cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(1LL*(cnt*(cnt+1)))/2;cnt=0;
                }
            }
            if(cnt)ans+=(1LL*(cnt*(cnt+1)))/2;
            cout<<ans<<endl;
            continue;
        }
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=1LL*(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        int cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        if(k==0)
        {
            int cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(LL)(pow(2,cnt)-1);cnt=0;
                }
            }
            if(cnt)ans+=(LL)(pow(2,cnt)-1);
            cout<<ans<<endl;
            continue;
        }
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=(LL)(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#define LL long long
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int k;
    while(cin>>k)
    {
        string s;
        cin>>s;
        LL ans=0;
        int cnt1=0,cnt0=0;
        bool flag=0;
        int len=s.length();
        if(k==0)
        {
            int cnt=0;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='0')
                {
                    cnt++;
                }
                else
                {
                    ans+=(LL)((cnt*(cnt+1))/2);cnt=0;
                }
            }
            if(cnt)ans+=(LL)((cnt*(cnt+1))/2);
            cout<<ans<<endl;
            continue;
        }
        int l=0;
        for(int i=0; i<len; i++)
        {
            if(s[i]=='1')
            {
                cnt1++;if(!flag)flag=1,l=i;
            }
            if(cnt1==k)
            {
                int a=0,b=0;
                for(int j=l-1;j>=0;j--)
                {
                    if(s[j]=='0')a++;
                    else break;
                }
                for(int j=i+1;j<len;j++)
                {
                    if(s[j]=='0')b++;
                    else break;
                }
                ans+=(LL)(a+b+a*b+1);
                i=l;
                cnt0=0;
                cnt1=0;flag=0;
            }
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	if (K == 0)
		{
			if (ch[n] != '1')
				seq_one[++cnt] = n + 1;
			for (int i = 1;i <= cnt;i++)
				ans += (seq_one[i] - seq_one[i - 1]) * (seq_one[i] - seq_one[i - 1] - 1) / 2;
		}else {
		seq_one[cnt + 1] = n + 1;
		for (int i = K;i <= cnt;i++)
			ans += (long long)(seq_one[i + 1] - seq_one[i]) * (seq_one[i - K + 1] - seq_one[i - K]);
	}
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	if (K == 0)
		{
			if (ch[n] != '1')
				seq_one[++cnt] = n + 1;
			for (int i = 1;i <= cnt;i++)
				ans += ((long long)seq_one[i] - seq_one[i - 1]) * (seq_one[i] - seq_one[i - 1] - 1) / 2;
		}else {
		seq_one[cnt + 1] = n + 1;
		for (int i = K;i <= cnt;i++)
			ans += ((long long)seq_one[i + 1] - seq_one[i]) * (seq_one[i - K + 1] - seq_one[i - K]);
	}
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	if (K == 0)
		{
			if (ch[n] != '1')
				seq_one[++cnt] = n;
			for (int i = 1;i <= cnt;i++)
				ans += (seq_one[i] - seq_one[i - 1]) * (seq_one[i] - seq_one[i - 1] - 1) / 2;
		}else {
		seq_one[cnt + 1] = n;
		for (int i = K;i <= cnt;i++)
			ans += (long long)(seq_one[i + 1] + seq_one[i] - seq_one[i - K] * 2) * (seq_one[i + 1] - seq_one[i]) / 2;
	}
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	if (K == 0)
		{
			if (ch[n] != '1')
				seq_one[++cnt] = n + 1;
			for (int i = 1;i <= cnt;i++)
				ans += (seq_one[i] - seq_one[i - 1]) * (seq_one[i] - seq_one[i - 1] - 1) / 2;
		}else {
		seq_one[cnt + 1] = n;
		for (int i = K;i <= cnt;i++)
			ans += (long long)(seq_one[i + 1] + seq_one[i] - seq_one[i - K] * 2) * (seq_one[i + 1] - seq_one[i]) / 2;
	}
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	int zeros = 0;
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
		else zeros++;
	if (K == 0)     {cout << zeros;return 0;}
	long long int ans = 0;
	seq_one[cnt + 1] = n;
	for (int i = K;i <= cnt;i++)
		ans += (long long)(seq_one[i + 1] + seq_one[i] - seq_one[i - K] * 2) * (seq_one[i + 1] - seq_one[i]) / 2;
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	if (K == 0)
		{
			if (ch[n] != '1')
				seq_one[++cnt] = n + 1;
			for (int i = 1;i <= cnt;i++)
				ans += (seq_one[i] - seq_one[i - 1]) * (seq_one[i] - seq_one[i - 1] - 1) / 2;
		}else {
		seq_one[cnt + 1] = n + 1;
		for (int i = K;i <= cnt;i++)
			ans += ((long long)seq_one[i + 1] - seq_one[i]) * (seq_one[i - K + 1] - seq_one[i - K]);
	}
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	seq_one[cnt + 1] = n;
	for (int i = K;i <= cnt;i++)
		ans += (long long)(seq_one[i + 1] + seq_one[i] - seq_one[i - K] * 2) * (seq_one[i + 1] - seq_one[i]) / 2;
	cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

int K,n;
int seq_one[1001000],cnt;
char ch[1001000];

int main()
{
	cin >> K;
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	for (int i = 1;i <= n;i++)
		if (ch[i] == '1')
			seq_one[++cnt] = i;
	long long int ans = 0;
	if (K == -1)
		{
			if (ch[n] != '1')
				seq_one[++cnt] = n + 1;
			for (int i = 1;i <= cnt;i++)
				ans += ((long long)seq_one[i] - seq_one[i - 1]) * (seq_one[i] - seq_one[i - 1] - 1) / 2;
		}else {
		seq_one[cnt + 1] = n + 1;
		for (int i = K;i <= cnt;i++)
			ans += ((long long)seq_one[i + 1] - seq_one[i]) * (seq_one[i - K + 1] - seq_one[i - K]);
	}
	cout << ans;
}


/***#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int *durations , first[1001] ,FOR_ZERO , length[1001] , sum , *solution , num , Total ;
bool one_time ;

void POSSIBLE(int i , int  sum , int index)
{

    if (sum == Total)
    {
        if(first[solution[0]] != 1 || length[index] != 1)
        {
            first[solution[0]] = 1;
            length[index] = 1;
            for(int h = 0 ; h < index ; h++)
            {
                printf("%d%c" , solution[h] , h!=index-1?'+':'\n');
            }
        }
        one_time = true;
    }
    else
    {
        for(int j = i ; j < num ; j++)
        {
            if(sum + durations[j] <=  Total)
            {
                solution[index] = durations[j];
                POSSIBLE(j+1 , sum + durations[j] , index+1 );
                solution[index] = 0;
            }
        }
    }
}

int main()
{
    while(cin >> Total >> num && num)
    {
        durations = new int [num];
        solution = new int [num];
        one_time = false;
        sum = 0;
        for(int i=0; i < num ; i++)
        {
            cin >> durations[i];
            sum+= durations[i];
        }
        if(sum < Total || (sum != 0 && Total==0)  )
        {
            cout << "Sums of " << Total << ":\n";
            cout << "NONE\n";
        }
        else if(sum == 0 && Total==0)
        {
            int val = 0;
             cout << "Sums of " << Total << ":\n";
            for(int i = 1 ; i<=num ; i++)
            {
                for(int g = 0 ; g <i ; g++)
                {
                  printf("%d%c" , val , g!=i-1?'+':'\n');
                }
            }
        }
        else
        {
            sort(durations,durations+num,greater<int>());
            sum = 0;
            cout << "Sums of " << Total << ":\n";
            POSSIBLE(0,sum,0);
            if(!one_time)
            {
                cout << "NONE\n";
            }

            for(int i=0 ; i<1001 ; i++)
            {
                first[i] = length[i] = 0;
            }
        }
    }
    return 0;
}*/
#include <iostream>
#include<string>
using namespace std;

long long solution[1000001];
int main()
{
    string inpute;
    int K;
    long long  counter = 0;
    int sum = 0;
    solution[0] = 1;

    cin>> K >> inpute;
    for(int i = 0; i < inpute.length() ; i++) {
        sum += (inpute[i]-'0');
        if(sum-K >= 0) {
            counter += solution[sum-K];
        }
        solution[sum]++;
    }
    cout<< counter << endl;

}


/***#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int *durations , first[1001] ,FOR_ZERO , length[1001] , sum , *solution , num , Total ;
bool one_time ;

void POSSIBLE(int i , int  sum , int index)
{

    if (sum == Total)
    {
        if(first[solution[0]] != 1 || length[index] != 1)
        {
            first[solution[0]] = 1;
            length[index] = 1;
            for(int h = 0 ; h < index ; h++)
            {
                printf("%d%c" , solution[h] , h!=index-1?'+':'\n');
            }
        }
        one_time = true;
    }
    else
    {
        for(int j = i ; j < num ; j++)
        {
            if(sum + durations[j] <=  Total)
            {
                solution[index] = durations[j];
                POSSIBLE(j+1 , sum + durations[j] , index+1 );
                solution[index] = 0;
            }
        }
    }
}

int main()
{
    while(cin >> Total >> num && num)
    {
        durations = new int [num];
        solution = new int [num];
        one_time = false;
        sum = 0;
        for(int i=0; i < num ; i++)
        {
            cin >> durations[i];
            sum+= durations[i];
        }
        if(sum < Total || (sum != 0 && Total==0)  )
        {
            cout << "Sums of " << Total << ":\n";
            cout << "NONE\n";
        }
        else if(sum == 0 && Total==0)
        {
            int val = 0;
             cout << "Sums of " << Total << ":\n";
            for(int i = 1 ; i<=num ; i++)
            {
                for(int g = 0 ; g <i ; g++)
                {
                  printf("%d%c" , val , g!=i-1?'+':'\n');
                }
            }
        }
        else
        {
            sort(durations,durations+num,greater<int>());
            sum = 0;
            cout << "Sums of " << Total << ":\n";
            POSSIBLE(0,sum,0);
            if(!one_time)
            {
                cout << "NONE\n";
            }

            for(int i=0 ; i<1001 ; i++)
            {
                first[i] = length[i] = 0;
            }
        }
    }
    return 0;
}*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string inpute;
    unsigned long long number ;
    unsigned long long now = 0;
    unsigned long long counter = 0;
    bool yes = false;
    ///while(  ){
    counter = 0;
    cin >> number >> inpute;
    if(inpute.find('0') == string::npos)
    {
        if(number == 1){
                cout << inpute.length() << endl;
        return 0;}
    }
    if(inpute.find('1') == string::npos)
    {
         if(number >0)
         {
             cout << "0\n";
             return 0;
         }
    }
    for(unsigned long long i = 0 ; i < inpute.length() ; i++)
    {
        if(number == 0)
        {
            yes = true;
        }
        else
        {
            yes = false;
        }
        now = 0;
        for(unsigned long long j = i ; j < inpute.length() ; j++)
        {
            if(inpute[j]=='0' && yes)
            {
                counter ++;
            }
            if(inpute[j]=='1')
            {
                if(now+1 == number)
                {
                    counter++;
                    yes = true;
                }
                else if (now+1 > number)
                {
                    break;
                }
                now++;
            }
        }

    }
    cout << counter << endl;
    ///}
    return 0;
}


/***#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int *durations , first[1001] ,FOR_ZERO , length[1001] , sum , *solution , num , Total ;
bool one_time ;

void POSSIBLE(int i , int  sum , int index)
{

    if (sum == Total)
    {
        if(first[solution[0]] != 1 || length[index] != 1)
        {
            first[solution[0]] = 1;
            length[index] = 1;
            for(int h = 0 ; h < index ; h++)
            {
                printf("%d%c" , solution[h] , h!=index-1?'+':'\n');
            }
        }
        one_time = true;
    }
    else
    {
        for(int j = i ; j < num ; j++)
        {
            if(sum + durations[j] <=  Total)
            {
                solution[index] = durations[j];
                POSSIBLE(j+1 , sum + durations[j] , index+1 );
                solution[index] = 0;
            }
        }
    }
}

int main()
{
    while(cin >> Total >> num && num)
    {
        durations = new int [num];
        solution = new int [num];
        one_time = false;
        sum = 0;
        for(int i=0; i < num ; i++)
        {
            cin >> durations[i];
            sum+= durations[i];
        }
        if(sum < Total || (sum != 0 && Total==0)  )
        {
            cout << "Sums of " << Total << ":\n";
            cout << "NONE\n";
        }
        else if(sum == 0 && Total==0)
        {
            int val = 0;
             cout << "Sums of " << Total << ":\n";
            for(int i = 1 ; i<=num ; i++)
            {
                for(int g = 0 ; g <i ; g++)
                {
                  printf("%d%c" , val , g!=i-1?'+':'\n');
                }
            }
        }
        else
        {
            sort(durations,durations+num,greater<int>());
            sum = 0;
            cout << "Sums of " << Total << ":\n";
            POSSIBLE(0,sum,0);
            if(!one_time)
            {
                cout << "NONE\n";
            }

            for(int i=0 ; i<1001 ; i++)
            {
                first[i] = length[i] = 0;
            }
        }
    }
    return 0;
}*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string inpute;
    int number ;
    int now = 0;
    int counter = 0;
    bool yes = false;
    ///while(  ){
                counter = 0;
                cin >> number >> inpute;
    for(int i = 0 ; i < inpute.length() ; i++)
    {
        yes = false;
        now = 0;
        for(int j = i ; j < inpute.length() ; j++)
        {
            if(inpute[j]=='0' && yes)
            {
                counter ++;
            }
            if(inpute[j]=='1')
            {
                if(now+1 == number)
                {
                    counter++;
                    yes = true;
                }
                else if (now+1 > number)
                {
                    break;
                }
                now++;
            }
        }
    }
    cout << counter << endl;
    ///}
    return 0;
}

/***
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int T, N, List[20];
vector<int> ans[10000];
int nOfans;

void backtracking(int pos, int sum)
{
    if (sum == T) {
        ans[nOfans+1] = ans[nOfans];
        ++nOfans;
        return;
    }
    for (int i = pos; i < N; ++i) {
        if (sum + List[i] <= T) {
            sum += List[i];
            ans[nOfans].push_back(List[i]);

            backtracking(i + 1, sum);

            sum -= List[i];
            ans[nOfans].pop_back();
        }
    }
}
bool cmp(vector<int> a, vector<int> b)
{
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] == b[i]) continue;
        return a[i] > b[i];
    }
    return a.size() > b.size();
}
void PrintOut(vector<int> &V)
{
    printf("%d", V[0]);
    for (int i = 1; i < V.size(); ++i)
        printf("+%d", V[i]);
    printf("\n");
}
int main()
{
    while (scanf("%d %d", &T, &N) && N) {
        for (int i = 0; i < N; ++i) {
            scanf("%d", &List[i]);
        }
        for (auto  &v : ans) v.clear();
        nOfans = 0;

        backtracking(0, 0);

        printf("Sums of %d:\n", T);
        if (nOfans == 0)
            puts("NONE");
        else {
            sort(ans, ans + nOfans, cmp);
            PrintOut(ans[0]);
            for (int i = 1;i < nOfans; ++i)
                if (ans[i] != ans[i-1]) // 確認答案是否已經存在
                    PrintOut(ans[i]);
        }
    }
}
*/


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string inpute;
    int number ;
    int now = 0;
    int counter = 0;
    bool yes = false;
    ///while(  ){
                counter = 0;
                cin >> number >> inpute;
                if(number == 0)
                {
                   for(int i = 0 ; i < inpute.length() ; i++)
                   {
                       if(inpute[i] == '0'){counter++;}
                   }
                }
                else{
    for(int i = 0 ; i < inpute.length() ; i++)
    {
        yes = false;
        now = 0;
        for(int j = i ; j < inpute.length() ; j++)
        {
            if(inpute[j]=='0' && yes)
            {
                counter ++;
            }
            if(inpute[j]=='1')
            {
                if(now+1 == number)
                {
                    counter++;
                    yes = true;
                }
                else if (now+1 > number)
                {
                    break;
                }
                now++;
            }
        }
    }
                }
    cout << counter << endl;
    ///}
    return 0;
}


/***#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int *durations , first[1001] ,FOR_ZERO , length[1001] , sum , *solution , num , Total ;
bool one_time ;

void POSSIBLE(int i , int  sum , int index)
{

    if (sum == Total)
    {
        if(first[solution[0]] != 1 || length[index] != 1)
        {
            first[solution[0]] = 1;
            length[index] = 1;
            for(int h = 0 ; h < index ; h++)
            {
                printf("%d%c" , solution[h] , h!=index-1?'+':'\n');
            }
        }
        one_time = true;
    }
    else
    {
        for(int j = i ; j < num ; j++)
        {
            if(sum + durations[j] <=  Total)
            {
                solution[index] = durations[j];
                POSSIBLE(j+1 , sum + durations[j] , index+1 );
                solution[index] = 0;
            }
        }
    }
}

int main()
{
    while(cin >> Total >> num && num)
    {
        durations = new int [num];
        solution = new int [num];
        one_time = false;
        sum = 0;
        for(int i=0; i < num ; i++)
        {
            cin >> durations[i];
            sum+= durations[i];
        }
        if(sum < Total || (sum != 0 && Total==0)  )
        {
            cout << "Sums of " << Total << ":\n";
            cout << "NONE\n";
        }
        else if(sum == 0 && Total==0)
        {
            int val = 0;
             cout << "Sums of " << Total << ":\n";
            for(int i = 1 ; i<=num ; i++)
            {
                for(int g = 0 ; g <i ; g++)
                {
                  printf("%d%c" , val , g!=i-1?'+':'\n');
                }
            }
        }
        else
        {
            sort(durations,durations+num,greater<int>());
            sum = 0;
            cout << "Sums of " << Total << ":\n";
            POSSIBLE(0,sum,0);
            if(!one_time)
            {
                cout << "NONE\n";
            }

            for(int i=0 ; i<1001 ; i++)
            {
                first[i] = length[i] = 0;
            }
        }
    }
    return 0;
}*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string inpute;
    long long number ;
    long long now = 0;
    long long counter = 0;
    bool yes = false;
    ///while(  ){
    counter = 0;
    cin >> number >> inpute;
    if(inpute.find('0') == string::npos)
    {
        if(number == 1){
                cout << inpute.length() << endl;
        return 0;}
    }
    if(inpute.find('1') == string::npos)
    {
         if(number == 0){
        cout << inpute.length()<< endl;
        return 0;
         }
         if(number >0)
         {
             cout << "0\n";
             return 0;
         }

    }
    for(int i = 0 ; i < inpute.length() ; i++)
    {
        if(number == 0)
        {
            yes = true;
        }
        else
        {
            yes = false;
        }
        now = 0;
        for(int j = i ; j < inpute.length() ; j++)
        {
            if(inpute[j]=='0' && yes)
            {
                counter ++;
            }
            if(inpute[j]=='1')
            {
                if(now+1 == number)
                {
                    counter++;
                    yes = true;
                }
                else if (now+1 > number)
                {
                    break;
                }
                now++;
            }
        }

    }
    cout << counter << endl;
    ///}
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string inpute;
    int number ;
    int now = 0;
    int counter = 0;
    bool yes = false;
    ///while(  ){
    counter = 0;
    cin >> number >> inpute;
    for(int i = 0 ; i < inpute.length() ; i++)
    {
        if(number == 0)
        {
            yes = true;
        }
        else
        {
            yes = false;
        }
        now = 0;
        for(int j = i ; j < inpute.length() ; j++)
        {
            if(inpute[j]=='0' && yes)
            {
                counter ++;
            }
            if(inpute[j]=='1')
            {
                if(now+1 == number)
                {
                    counter++;
                    yes = true;
                }
                else if (now+1 > number)
                {
                    break;
                }
                now++;
            }
        }

    }
    cout << counter << endl;
    ///}
    return 0;
}


/***#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int *durations , first[1001] ,FOR_ZERO , length[1001] , sum , *solution , num , Total ;
bool one_time ;

void POSSIBLE(int i , int  sum , int index)
{

    if (sum == Total)
    {
        if(first[solution[0]] != 1 || length[index] != 1)
        {
            first[solution[0]] = 1;
            length[index] = 1;
            for(int h = 0 ; h < index ; h++)
            {
                printf("%d%c" , solution[h] , h!=index-1?'+':'\n');
            }
        }
        one_time = true;
    }
    else
    {
        for(int j = i ; j < num ; j++)
        {
            if(sum + durations[j] <=  Total)
            {
                solution[index] = durations[j];
                POSSIBLE(j+1 , sum + durations[j] , index+1 );
                solution[index] = 0;
            }
        }
    }
}

int main()
{
    while(cin >> Total >> num && num)
    {
        durations = new int [num];
        solution = new int [num];
        one_time = false;
        sum = 0;
        for(int i=0; i < num ; i++)
        {
            cin >> durations[i];
            sum+= durations[i];
        }
        if(sum < Total || (sum != 0 && Total==0)  )
        {
            cout << "Sums of " << Total << ":\n";
            cout << "NONE\n";
        }
        else if(sum == 0 && Total==0)
        {
            int val = 0;
             cout << "Sums of " << Total << ":\n";
            for(int i = 1 ; i<=num ; i++)
            {
                for(int g = 0 ; g <i ; g++)
                {
                  printf("%d%c" , val , g!=i-1?'+':'\n');
                }
            }
        }
        else
        {
            sort(durations,durations+num,greater<int>());
            sum = 0;
            cout << "Sums of " << Total << ":\n";
            POSSIBLE(0,sum,0);
            if(!one_time)
            {
                cout << "NONE\n";
            }

            for(int i=0 ; i<1001 ; i++)
            {
                first[i] = length[i] = 0;
            }
        }
    }
    return 0;
}*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string inpute;
    long long number ;
    long long now = 0;
    long long counter = 0;
    bool yes = false;
    ///while(  ){
    counter = 0;
    cin >> number >> inpute;
    if(inpute.find('0') == string::npos)
    {
        if(number == 1){
                cout << inpute.length() << endl;
        return 0;}
    }
    if(inpute.find('1') == string::npos)
    {
         if(number == 0){

        unsigned long int sum = 1;
        for(unsigned long int i =1 ; i <= inpute.length() ; i++)
        {
            sum*=i;
        }
        cout << sum << endl;
        return 0;
         }
         if(number >0)
         {
             cout << "0\n";
         }

    }
    for(int i = 0 ; i < inpute.length() ; i++)
    {
        if(number == 0)
        {
            yes = true;
        }
        else
        {
            yes = false;
        }
        now = 0;
        for(int j = i ; j < inpute.length() ; j++)
        {
            if(inpute[j]=='0' && yes)
            {
                counter ++;
            }
            if(inpute[j]=='1')
            {
                if(now+1 == number)
                {
                    counter++;
                    yes = true;
                }
                else if (now+1 > number)
                {
                    break;
                }
                now++;
            }
        }

    }
    cout << counter << endl;
    ///}
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

const int N = 1000000;

int main() {
	char A[N];
	int k;
	scanf("%d", &k);
	scanf("%s", A);
	int n = strlen(A);

	if (k == 0) {
		int dp[N];
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			if (A[i] == '1') dp[i] = 0;
			else dp[i] = (i == 0 ? 0 : dp[i - 1]) + 1;
		}

		ll ans = 0;
		for (int i = 0; i < n; i++)
			if (A[i] == '0' && (i == n - 1 || A[i + 1] == '1'))
				ans += ((ll)dp[i] + 1l)*(ll)dp[i] / 2;

		printf("%I64d\n", ans);
		return 0;
	}

	int dp[N],pre[N],next[N];
	memset(dp, 0, sizeof(dp));
	memset(pre, -1, sizeof(pre));
	memset(next, -1, sizeof(next));

	for (int i = 0; i < n; i++) {
		dp[i] = (i == 0 ? 0 : dp[i - 1]);
		if (A[i] == '1') dp[i]++;
	}

	int cur = -1;
	for (int i = 0; i < n; i++)
		if (A[i] == '1') {
			pre[i] = cur;
			cur = i;
		}

	cur = n;
	for (int i = n - 1; i >= 0; i--)
		if (A[i] == '1') {
			next[i] = cur;
			cur = i;
		}

	int l = 0, r = 0;
	ll ans = 0;

	while (l < n && r < n) {
		while (r < n && dp[r] - (l == 0 ? 0 : dp[l - 1]) < k) r++;
		while (l < n && A[l] != '1') l++;

		if (l >= n || r >= n) break;

		ans += (ll)(next[r] - r)*(ll)(l - pre[l]);
		l++;
	}

	printf("%I64d\n", ans);

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

const int N = 1000000;

int main() {
	char A[N];
	int k;
	scanf("%d", &k);
	scanf("%s", A);
	int n = strlen(A);

	int dp[N],pre[N],next[N];
	memset(dp, 0, sizeof(dp));
	memset(pre, -1, sizeof(pre));
	memset(next, -1, sizeof(next));

	for (int i = 0; i < n; i++) {
		dp[i] = (i == 0 ? 0 : dp[i - 1]);
		if (A[i] == '1') dp[i]++;
	}

	int cur = -1;
	for (int i = 0; i < n; i++)
		if (A[i] == '1') {
			pre[i] = cur;
			cur = i;
		}

	cur = n;
	for (int i = n - 1; i >= 0; i--)
		if (A[i] == '1') {
			next[i] = cur;
			cur = i;
		}

	int l = 0, r = 0;
	ll ans = 0;

	while (l < n && r < n) {
		while (r < n && dp[r] - (l == 0 ? 0 : dp[l - 1]) < k) r++;
		while (l < n && A[l] != '1') l++;

		if (l >= n || r >= n) break;

		ans += (next[r] - r)*(l - pre[l]);
		l++;
	}

	printf("%I64d\n", ans);

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

const int N = 1000;

int main() {
	char A[N];
	int k;
	scanf("%d", &k);
	scanf("%s", A);
	int n = strlen(A);

	if (k == 0) {
		int dp[N];
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			if (A[i] == '1') dp[i] = 0;
			else dp[i] = (i == 0 ? 0 : dp[i - 1]) + 1;
		}

		ll ans = 0;
		for (int i = 0; i < n; i++)
			if (A[i] == '0' && (i == n - 1 || A[i + 1] == '1'))
				ans += (dp[i] + 1)*dp[i] / 2;

		printf("%I64d\n", ans);
		return 0;
	}

	int dp[N],pre[N],next[N];
	memset(dp, 0, sizeof(dp));
	memset(pre, -1, sizeof(pre));
	memset(next, -1, sizeof(next));

	for (int i = 0; i < n; i++) {
		dp[i] = (i == 0 ? 0 : dp[i - 1]);
		if (A[i] == '1') dp[i]++;
	}

	int cur = -1;
	for (int i = 0; i < n; i++)
		if (A[i] == '1') {
			pre[i] = cur;
			cur = i;
		}

	cur = n;
	for (int i = n - 1; i >= 0; i--)
		if (A[i] == '1') {
			next[i] = cur;
			cur = i;
		}

	int l = 0, r = 0;
	ll ans = 0;

	while (l < n && r < n) {
		while (r < n && dp[r] - (l == 0 ? 0 : dp[l - 1]) < k) r++;
		while (l < n && A[l] != '1') l++;

		if (l >= n || r >= n) break;

		ans += (next[r] - r)*(l - pre[l]);
		l++;
	}

	printf("%I64d\n", ans);

	return 0;
}