#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> ans;
  vector<char> a(n + 1, 'a');
  int k = 1;
  int x = 'a';
  int y = 'a';
  for (int i = 0; i < n; i++) {
    bool found = false;
    for (int j = 0; j < k; j++) {
      if (s[i] >= a[j]) {
        a[j] = s[i];
        ans.push_back(j + 1);
        found = true;
        break;
      }
    }
    if (!found) {
      a[k] = s[i];
      ans.push_back(k + 1);
      k++;
    }
  }
  cout << k << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
