#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> last(n);
    vector<deque<int>> cnt(n);
    for (int i = 0; i < s.size(); ++i) {
        last[s[i] - 'a'] = i;
        cnt[s[i] - 'a'].push_back(i);
    }

    int max_pos = -1;
    int ans = 0;
    while (true) {
        ++ans;
        bool can_add = true;
        int cur_max_pos = max_pos;
        for (int j = 0; j < n; ++j) {
            if (!cnt[j].size() || cnt[j].back() <= max_pos) {
                can_add = false;
                continue;
            }
            while (cnt[j].front() <= max_pos) {
                cnt[j].pop_front();
            }
            cur_max_pos = max(cur_max_pos, cnt[j].front());
        }
        if (can_add) {
            max_pos = cur_max_pos;
        }
        else {
            break;
        }
    }
    cout << ans;
}

signed main() {
    int t = 1;
    //    cin >> t;
    while (t--) {
        solve();
    }
}