#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstring>
using namespace std;
using ll = long long;
#define ALL(a) (a).begin(), (a).end()

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
const int MOD = 1000000007;
#define LLONG_MAXs 9223372036854775800 / 2

#define ALL(a) (a).begin(), (a).end()

#include <iostream>
#include <cmath>
using namespace std;

bool isPrimeNum(ll x)
{ // 素数である場合 true を返す
	if (x <= 1)
	{ // 1以下である場合は素数でないことがすぐにわかる
		return false;
	}
	// sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
	int n = (int)sqrt((double)x);
	for (int i = 2; i <= n; i++)
	{
		if (x % i == 0)
		{ // 割り切る整数がある場合、即判定終了
			return false;
		}
	}
	return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll abs(ll a, ll b)
{
	if (a >= b)
		return a - b;
	if (a < b)
		return b - a;
}
constexpr double dabs(double a, double b)
{
	if (a >= b)
		return a - b;
	if (a < b)
		return b - a;
}
constexpr ll min(ll a, ll b)
{
	if (a >= b)
		return b;
	if (a < b)
		return a;
}

constexpr ll max(ll a, ll b)
{
	if (a >= b)
		return a;
	if (a < b)
		return b;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int dx8[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <iostream>
#include <vector>
using namespace std;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
// modint (1000000007 で割ったあまりを扱う構造体)
template <int MOD>
struct Fp
{
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v % MOD)
	{
		if (val < 0)
			v += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator-() const noexcept
	{
		return val ? MOD - val : 0;
	}
	constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp &operator+=(const Fp &r) noexcept
	{
		val += r.val;
		if (val >= MOD)
			val -= MOD;
		return *this;
	}
	constexpr Fp &operator-=(const Fp &r) noexcept
	{
		val -= r.val;
		if (val < 0)
			val += MOD;
		return *this;
	}
	constexpr Fp &operator*=(const Fp &r) noexcept
	{
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp &operator/=(const Fp &r) noexcept
	{
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b)
		{
			long long t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0)
			val += MOD;
		return *this;
	}
	constexpr bool operator==(const Fp &r) const noexcept
	{
		return this->val == r.val;
	}
	constexpr bool operator!=(const Fp &r) const noexcept
	{
		return this->val != r.val;
	}
	friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
	{
		return os << x.val;
	}
	friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept
	{
		return is >> x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
	{
		if (n == 0)
			return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1)
			t = t * a;
		return t;
	}
};

// 二項係数ライブラリ
template <class T>
struct BiCoef
{
	vector<T> fact_, inv_, finv_;
	constexpr BiCoef() {}
	constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1)
	{
		init(n);
	}
	constexpr void init(int n) noexcept
	{
		fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
		int MOD = fact_[0].getmod();
		for (int i = 2; i < n; i++)
		{
			fact_[i] = fact_[i - 1] * i;
			inv_[i] = -inv_[MOD % i] * (MOD / i);
			finv_[i] = finv_[i - 1] * inv_[i];
		}
	}
	constexpr T com(int n, int k) const noexcept
	{
		if (n < k || n < 0 || k < 0)
			return 0;
		return fact_[n] * finv_[k] * finv_[n - k];
	}
	constexpr T fact(int n) const noexcept
	{
		if (n < 0)
			return 0;
		return fact_[n];
	}
	constexpr T inv(int n) const noexcept
	{
		if (n < 0)
			return 0;
		return inv_[n];
	}
	constexpr T finv(int n) const noexcept
	{
		if (n < 0)
			return 0;
		return finv_[n];
	}
};

using mint = Fp<MOD>;
BiCoef<mint> bc;

void yn(bool flag)
{
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return;
}
void YN(bool flag)
{
	if (flag)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return;
}

std::vector<ll> enum_div(ll n) //nの約数を列挙
{
	std::vector<ll> ret;
	for (ll i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i * i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	ret.push_back(n);
	return ret;
}

// グラフセット
struct Edge
{
	ll to;	 // 辺の行き先
	ll weight; // 辺の重み
	Edge(int t, int w) : to(t), weight(w) {}
};
//using Graph = vector<vector<Edge>>;
using Graph = vector<vector<ll>>;

vector<vector<int>> G;

//cout<<std::setprecision(30)
int main() {
	ll N;
	cin >> N;
	string S;
	cin >> S;
	ll ans = 0;
	FOR(i, 2, S.size() - 1)
	{
		if(S[i-2]=='A'&&S[i-1]=='B'&&S[i]=='C')
			ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256