#include <iostream>
#include <vector>
#include <numeric>

using namespace std;


void weather_predicition()
{
  string s;
  cin >> s;

  if (s == "Sunny") cout << "Cloudy\n";
  else if (s == "Cloudy") cout << "Rainy\n";
  else if (s == "Rainy") cout << "Sunny\n";
}


void odds_of_oddness()
{
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 1; i <= n; ++i)
  {
    if (i % 2 != 0) ++cnt;
  }

  cout << (float)cnt / (float)n << "\n";
}


void curtain()
{
  int a, b;
  cin >> a >> b;

  if (a - 2 * b > 0) cout << a - 2 * b << "\n";
  else cout << 0 << "\n";
}


void cant_wait_for_holiday()
{
  string s;
  cin >> s;

  vector<string> S{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  int cnt = 7;
  for (int i = 0; i < 7; ++i)
  {
    if (s == S[i]) cout << cnt << "\n"; 
    --cnt;
  }

}


void blackjack()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  if (accumulate(a.begin(), a.end(), 0) >= 22) cout << "bust\n";
  else cout << "win\n";
}


void round_one()
{
  int a, b;
  cin >> a >> b;

  cout << 6 - a - b;
}


void strings()
{
  string s, t;
  cin >> s >> t;

  cout << t + s << "\n";
}


void yen_conins()
{
  int k, x;
  cin >> k >> x;

  if (k * 500 - x >= 0) cout << "Yes\n";
  else cout << "No\n";
}


void tap_dance() 
{
  string s;
  cin >> s;

  int flag = 1;
  for (int i = 1; i <= s.size(); ++i)
  {
    if (i % 2 == 0)
    {
      if (s[i] == 'L') flag = 0;
    }
    else
    {
      if (s[i] == 'R' ) flag = 0;
    }
  }
  if (flag) cout << "Yes\n";
  else cout << "No\n";
}


void roller_coaster()
{
  int n, k;
  cin >> n >> k;

  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    int h;
    cin >> h;
    if (h >= k) ++cnt;
  }
  cout << cnt << "\n";
}


void takoyaki_festival2019()
{
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];

  int v_sum = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      v_sum += d[i] * d[j];
    }
  }
  cout << v_sum << "\n";
}


void echo()
{
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 != 0)
  {
    cout << "No\n";
    return;
  }

  for (int i = 0; i < n / 2; ++i)
  {
    if (s[i] != s[i + n / 2])
    {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}


void rot_n()
{
  int n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < s.size(); ++i)
  {
    s[i] = 'A' + (s[i] - 'A' + n) % 26;
  }
  cout << s << "\n";
}


void palindrom_philia()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < s.size() / 2; ++i)
  {
    if (s[i] != s[s.size() - i - 1]) ++cnt;
  }
  cout << cnt << "\n";
}


void strings_with_the_same_length()
{
  int n;
  string s, t;
  cin >> n >> s >> t;

  string ans = "";
  for (int i = 0; i < n; ++i)
  {
    ans += s[i];
    ans += t[i];
  }
  cout << ans << "\n";
}

void greedy_takahashi()
{
  long long int a, b, k;
  cin >> a >> b >> k;

  if (a >= k) cout << a - k << " " << b << "\n";
  else if (a + b >= k) cout << 0 << " " << b - (k - a) << "\n";
  else cout << 0 << " " << 0 << "\n";
}

void count_ABC()
{
  int n;
  string s;
  cin >> n >> s;

  int cnt = 0;
  for (int i = 0; i < n - 2; ++i)
  {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ++cnt;
  }
  cout << cnt << "\n";
}



int main()
{
  //weather_predicition();
  //odds_of_oddness();
  //curtain();
  //cant_wait_for_holiday();
  //blackjack();
  //round_one();
  //strings();
  //yen_conins();

  //tap_dance();
  //roller_coaster();
  //takoyaki_festival2019();
  //echo();
  //rot_n();
  //palindrom_philia();
  //strings_with_the_same_length();
  //greedy_takahashi();
  count_ABC();
}

Measured memory_bytes: 256