コード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
if (!v.empty()) {
out << '[';
std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
out << "\b\b]";
}
return out;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
string S;
cin >> S;
vector<int> cnt(26, 0);
for (int i = 0; i < S.size(); ++i) {
if (i % 2 == 0) cnt[S[i] - 'a']++;
}
vector<int> ccnt(10, 0);
for (int i = 0; i < cnt.size(); ++i) {
ccnt[cnt[i]]++;
}
int ans = 0;
for (int i = 1; i <= 9; ++i) {
if (i == 1 && ccnt[i] > 0) {
ans += ccnt[i] * 2;
continue;
}
if (ccnt[i] == 1) {
ans += 4;
} else if (ccnt[i] > 1) {
ans += (ccnt[i] * 2 + 4);
}
}
ans--;
cout << ans << endl;
}