#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9 + 1e8;
const long long INF = 2e18 + 1e17;
const int mod = 998244353;
const int MOD = 1e9 + 7;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
bool is_prime(long long x) {
  if (x == 1 || (x % 2 == 0 && x > 2)) return false;
  for (int i = 3; i * i <= x; i += 2) {
    if (!(x % i)) {
      return false;
    }
  }
  return true;
}
const int MAXN = 200010;
int N;
string str;
int dp[MAXN][30], ans[MAXN];
int res;
int main() {
  cin >> N >> str;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 26; j++) {
      if (i != 0) dp[i][j] = dp[i - 1][j];
    }
    int x = str[i] - 'a';
    x = 25 - x;
    if (i == 0) {
      dp[i][x] = 1;
    } else {
      if (x != 0)
        dp[i][x] = dp[i - 1][x - 1] + 1;
      else
        dp[i][x] = 1;
    }
    ans[i] = dp[i][x];
    for (int j = 1; j < 26; j++) {
      dp[i][j] = max(dp[i][j], dp[i][j - 1]);
    }
  }
  res = dp[N - 1][25];
  cout << res << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}
