This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to color all its characters one of the two colors (each character to exactly one color, the same letters can be colored the same or different colors, i.e. you can choose exactly one color for each index in $$$s$$$).After coloring, you can swap any two neighboring characters of the string that are colored different colors. You can perform such an operation arbitrary (possibly, zero) number of times.The goal is to make the string sorted, i.e. all characters should be in alphabetical order.Your task is to say if it is possible to color the given string so that after coloring it can become sorted by some sequence of swaps. Note that you have to restore only coloring, not the sequence of swaps.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the length of $$$s$$$. The second line of the input contains the string $$$s$$$ consisting of exactly $$$n$$$ lowercase Latin letters.

If it is impossible to color the given string so that after coloring it can become sorted by some sequence of swaps, print "NO" (without quotes) in the first line. Otherwise, print "YES" in the first line and any correct coloring in the second line (the coloring is the string consisting of $$$n$$$ characters, the $$$i$$$-th character should be '0' if the $$$i$$$-th character is colored the first color and '1' otherwise).

#include <bits/stdc++.h>
#define ll long long int
#define N 5000000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb emplace_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */
int main()
{
  //  freopen("input.txt", "r", stdin);

    ll n;
    cin >> n;
    string s;
    cin >> s;
     bool ok = true;

     vector <pair<ll,ll>> ass(n);

     f(i,0,n-1)
     ass[i].first=i,ass[i].second=-1;

    f(i, 0, n - 2)
    {
        f(j, 0, n - i - 2)
        {

            if (s[j] > s[j + 1])
            {
                if (ass[j].second == -1 && ass[j + 1].second == -1)
                {
                    ass[j].second = 0;
                    ass[j + 1].second = 1;
                }
                else if (ass[j].second == -1 && ass[j + 1].second != -1)
                {
                    ass[j].second = ass[j + 1].second == 0 ? 1 : 0;
                }
                else if (ass[j].second != -1 && ass[j + 1].second == -1)
                {
                    ass[j + 1].second = ass[j].second == 0 ? 1 : 0;
                }
                else if (ass[j].second == ass[j + 1].second)
                {
                    ok = false;
                    break;
                }
                 swap(ass[j],ass[j+1]);
                 swap(s[j],s[j+1]);
               }
        }
        if (!ok)
            break;
    }

    if (!ok)
    {
        cout << "NO";
        return 0;
    }
    cout << "YES\n";

     f(i,0,n-1)
     {
         f(j,0,n-1)
         {
             if(ass[j].fi == i)
             {
                 ll ans=ass[j].se == -1?0:ass[j].se;
                 cout << ans ;
                 break;
             }
         }
     }
}

// Author: 23forever
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline int read() {
  int x = 0, w = 1; char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * w;
}
inline void write(int x) {
  static char sta[10]; static int top;
  if (x < 0) putchar('-'), x = -x;
  while(sta[++top] = x % 10 ^ 48, x /= 10) continue;
  while (top) putchar(sta[top--]);
  putchar('\n');
}

int n, len, que[MAXN + 5], que2[MAXN + 5], len2;
char s[MAXN + 5];

void init() {
  n = read(); scanf("%s", s + 1);
}

int res[MAXN + 5];

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  init();

  que[++len] = s[1], que2[++len2] = s[1];
  for (int i = 2; i <= n; ++i) {
    if (que[len] > s[i]) {
      que[++len] = s[i];
    } else {
      int k = lower_bound(que + 1, que + 1 + len, s[i], greater<int>()) - que;
      que[k] = s[i];
    }
  }

  if (len <= 2) {
    puts("Yes");
    int cur1 = 0, cur2 = 0;
    for (int i = 1; i <= n; ++i) {
      if (s[i] < cur1) {
        cur2 = s[i], res[i] = 1;
      } else if (s[i] < cur2) {
        cur1 = s[i], res[i] = 0;
      } else {
        if (s[i] - cur1 <= s[i] - cur2) {
          cur1 = s[i], res[i] = 0;
        } else {
          cur2 = s[i], res[i] = 1;
        }
      }
    }
    for (int i = 1; i <= n; ++i) printf("%d", res[i]);
    printf("\n");
  } else {
    puts("No");
  }
#ifdef forever23
  printf("Running Time = %d ms\n", int(clock() * 1000.0 / CLOCKS_PER_SEC));
#endif
}

#include <bits/stdc++.h>
#define all(nums) nums.begin(), nums.end()
typedef long long int ll;
const int imax = INT32_MAX;
const int imin = INT32_MIN;
using namespace std;
const int mx = 10e5 + 10;
const long MOD=1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t = 1;
    // cin>>t;
    while (t--) {
        int n;
        cin>>n;
        string s;
        cin>>s;

        vector<int>dp(n, 1);
        for (int i=0; i<n; ++i) {
            for (int j=0; j<i; ++j) {
                if (s[j]>s[i]) {
                    dp[i]=max (dp[i], 1+dp[j]);
                }
            }
        }
        int val=*max_element(all(dp));
        if (val > 2)    cout<<"NO";
        else {
            cout<<"YES\n";
            for (int i:dp)  cout<<i-1;
        }
    }
    return 0;
}

#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>

using namespace std;

vector<int> link[201];
int color[201];
bool visited[201];

bool dfs(int cur, int bit)
{
	if (color[cur] != -1 && color[cur] != bit)
	{
		return false;
	}

	bool valid = true;

	color[cur] = bit;

	for (int i = 0; i < link[cur].size(); i++)
	{
		int next;

		next = link[cur][i];

		if (color[next] == -1)
		{
			valid = (valid&&dfs(next, !bit));
		}

		else if(color[next]==color[cur])
		{
			return false;
		}
	}

	return valid;
}

int main()
{
	int n;
	string str;
	char input[201];

	memset(color, -1, sizeof(color));

	scanf("%d", &n);

	scanf("%s", input);

	str = input;

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < i; j++)
		{
			if (str[j] > str[i])
			{
				link[i].push_back(j);
				link[j].push_back(i);
			}
		}
	}

	bool valid = true;

	string rmin;

	rmin = str;

	for (int i = 0; i < n; i++)
	{
		if (color[i] == -1)
		{
			valid = (valid&&dfs(i,0));
		}

		if(!valid)
		{
			printf("NO\n");

			return 0;
		}
	}

	printf("YES\n");

	for (int i = 0; i < n; i++)
	{
		printf("%d", color[i]);
	}

	printf("\n");

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define vi vector<ll>
#define vii vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) c.begin(),c.end()
#define sz(c) (ll)c.size()
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define init(x,a) memset(x,a,sizeof(x))
#define lbd(a,val) lower_bound(all(a),val)
#define ubd(a,val) upper_bound(all(a),val)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
#define mod (ll)1000000007
#define M (ll)998244353
#define N 5002
#define PI 3.14159265358979323846
ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    else if(y%2 == 0)        //n is even
        return power((x*x)%mod,y/2);
    else                             //n is odd
        return (x*power((x*x)%mod,(y-1)/2))%mod;

}
ll modInverse(ll n)
{
    return power(n,mod-2);
}
int a[26],ans[200005];
int main()
{
//	IOS;
	int t=1;
//	cin>>t;
	while(t--)
	{
		ll n,c=0;
		string s;
		cin>>n>>s;
		f(i,0,n){
			for(ll j=s[i]-'a';j>=0;j--){
				if(a[j]){
					ans[i]=a[j];
					if(j!=s[i]-'a'){
						a[s[i]-'a']=a[j];
						a[j]=0;
					}
					break;
				}
			}
			if(!ans[i]){
				c++;
				ans[i]=c;
				a[s[i]-'a']=c;
			}
		}
		if(c>2) cout<<"NO"<<en;
		else{
			cout<<"YES"<<en;
			f(i,0,n) cout<<ans[i]-1;
		}
	}
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long int
int32_t main(){

    int n;
    cin>>n;
    string s;
    cin>>s;

    int dp[n+1];
    memset(dp,0,sizeof(dp));

    int prev = 0 ;

    int val = 1;

    while(1 )
    {

        int min = s[prev];
        for(int i = prev ; i < n ; i ++){

            if(s[i] >= min && dp[i] == 0){
                min = s[i];

                dp[i] = val;
            }

        }

        for(int i = 0 ; i < n ; i ++ ){
            if(dp[i] == 0){
                prev = i;break;}
        }

        val++;
        // if(prev == n-1)break;

        bool flag=true;
        for(int i = 0 ; i < n ; i ++) {
            if(dp[i]==0)flag=false;

        }
        if(flag)break;

    }

    // cout<<val-1<<endl;

    if(val-1 <= 2)
    {
    cout<<"Yes\n";
    for(int i  = 0 ; i  < n ; i++) {cout<<dp[i]-1;
    }

    }
    else
        cout<<"No\n";

}

/*
  AUTHOR:SOURABH
  CREATED:04:02:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,n,i,j,ma,res;
    string s;
    //cin>>t;
    t=1;
    W(t--)
    {
        cin>>n;
        cin>>s;
        vll ans(n);
        ll a[26]={0};
        res=0;
        fn(i,n)
        {
            ma=0;
            fs(j,s[i]-'a'+1,26)
            ma=max(a[j],ma);
            ans[i]=ma+1;
            res=max(res,ans[i]);
            a[s[i]-'a']=max(a[s[i]-'a'],ans[i]);
        }
        if(res>2)
        {cout<<"NO\n";continue;}
        cout<<"YES\n";
        fn(i,n)
        cout<<ans[i]%2;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define db double
#define vi vector<int>
#define vvi vector<vector<int> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define mem(a,b) memset(a , b , sizeof a ) ;
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mp make_pair
#define all(v) v.begin(),v.end()

#define deb1(a) cout<<"!a="<<a<<endl;
#define deb2(a) cout<<"@a="<<a<<endl;
#define deb3(a) cout<<"#a="<<a<<endl;
#define deb4(a,b) cout<<"$a="<<a<<" and b="<<b<<endl;
#define deb5(a,b) cout<<"%a="<<a<<" and b="<<b<<endl;
#define deb6(a,b) cout<<"^a="<<a<<" and b="<<b<<endl;

int main()
{
	speed
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<set<int> > v(26);
	v[s[0]-'a'].insert(1);
	int col[n];
	mem(col,0);
	col[0]=1;
	int f[26];
	mem(f,0);
	f[s[0]-'a']=1;
	int cnt=1;
	ll ss=0;
	rep(i,0,n)
	{
		if(!f[s[i]-'a']){
			ss++;
			f[s[i]-'a']=1;
		}
	}
//	cout<<"ss="<<ss<<endl;
	mem(f,0);
	rep(i,1,n)
	{
		ll c[26];
		mem(c,1);
		f[s[i]-'a']=1;
		rep(j,s[i]-'a'+1,26)
		{	set<int> ::iterator k;
			for(k=v[j].begin();k!=v[j].end();k++) {

	//	if((i==192||i==54||i==60||i==69||i==77||i==9)&&c[*k]!=0)	cout<<"for i="<<i<<" false "<<*k<<" for "<<(char)('a'+j)<<endl;
			c[*k]=0;
			}
		}
	/*	int z=s[i]-'a'-1;
		while(z>=0&&f[z]==0) z--;

		if(z!=-1&&c[*v[z].begin()]){
			col[i]=*v[z].begin();
			v[s[i]-'a'].insert(col[i]);
			cnt=max(cnt,col[i]);
		//	cout<<"**col["<<i<<"]="<<col[i]<<endl;
			continue;
		}*/
		ll zz=1;
		while(!c[zz]) zz++;
		col[i]=zz;
		v[s[i]-'a'].insert(col[i]);
		//cout<<"$$col["<<i<<"]="<<col[i]<<endl;
		cnt=max(cnt,col[i]);

	}
	if(cnt<=2) {
		cout<<"YES\n";
		rep(i,0,n) cout<<col[i]-1;
	}
	else cout<<"NO\n";
	//cout<<cnt<<endl;
	//rep(i,0,n) cout<<col[i]<<" ";
//aaabbcbb

}

#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long int
#define d double
#define f(i,x,n) for(ll i=x;i<n;i++)
using namespace std;
int main(){
	int n;
	string s,ans;
	cin>>n>>s;
	int a[n];
	memset(a,0,sizeof(a));
	vector<char> v,q;
	f(i,0,n-1){
       if(s[i+1]<s[i]){
			a[i+1]=1;
			char x=s[i];
			while(s[i+1]<x){
				a[i+1]=1;
				i++;
				if(i==n-1) break;
			}
		}
	}
	f(i,0,n){
		if(a[i]==1) q.push_back(s[i]);
		else v.push_back(s[i]);
	}
 int f1=0;
 if(q.size()){
  f(i,0,q.size()-1){
 	if(q[i+1]<q[i]) {
 		f1=1;
 		break;
	 }
 }
 }

 if(f1!=0)  cout<<"NO";
 else ans="YES";
 if(ans=="YES"){
 	cout<<"YES"<<endl;
 	f(i,0,n){
 		cout<<a[i];
	 }
 }

return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define mp make_pair
#define mt make_tuple
#define get(x,c) get<x>(c)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define rep(i,n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define f first
#define s second

inline ll max(ll a,ll b) {return((a>b)?a:b);}
inline ll min(ll a,ll b) {return((a>b)?b:a);}
inline ll gcd(ll a,ll b) {if(b==0)return a;a%=b;return gcd(b,a);}
ll power(ll x,ll y){if(y==0) return 1;ll a=power(x,y/2);if(y%2==0) return a*a;else return x*a*a;}
ll powermod(ll x,ll ex,ll md){ll ans=1ll;while(ex>0){if(ex&1ll) ans=(ans*x)%md; ex>>=1ll;x=(x*x)%md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 2e2 + 11;
ll n,col[N];
string s;
void solve(){
    cin>>n>>s;
    rep(i,n) col[i]=-1;
    rep(i,n){
        if(col[i]==-1)col[i]=0;
        for(ll j=i+1;j<n;j++){
            if(s[j]<s[i]){
                if(col[j]==-1) col[j]=(col[i]^1);
                else if(col[j]!=(col[i]^1)){
                    cout<<"NO\n";
                    return;
                }
            }
        }
    }
    cout<<"YES\n";
    rep(i,n) cout<<col[i];
    nl;
}
int main(){
    IOS;
    cout<<fixed<<setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while((PTC++)<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
        cout<<"\n";
    }
    cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
}

#include <cassert>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

const int mxN = 200;
int color[mxN];
vector<int> adj[mxN];

bool set_color(int node, int c) {
	color[node] = c;
	for (int v : adj[node]) {
		if ((color[v] == c) || (color[v] == -1 && !set_color(v, !c))) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	memset(color, -1, mxN * sizeof(color[0]));
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] > s[j]) {
				adj[i].push_back(j);
				adj[j].push_back(i);
			}
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (color[i] == -1) {
			if (!set_color(i, 0)) {
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES\n";
	for (int i = 0; i < s.size(); i++) {
		cout << color[i];
	}
}

// C++ function for illustration
// map::lower_bound() function
#include <bits/stdc++.h>
using namespace std;

int main()
{
 int n;
 string s;
 cin>>n;
 cin>>s;
 //int z=s.size();
 int ar[28];
 memset(ar,-1,sizeof(ar));
 string s1="";
int ma=INT_MIN;
bool f=true;

 for (int i = 0; i < n; ++i)
 {
  int x=int(s[i])-97;
  if(ma<=x){ if(ar[x]==-1){s1=s1+"0"; ar[x]=0; ma=x;continue;} if(ar[x]==0 || ar[x]==1){ int x1=ar[x]; s1=s1+to_string(x1); ma=x; continue;  } s1=s1+"1";ma=x;continue;  }
  bool ze=false,on=false;
  for(int j=x+1;j<=ma;j++)
  {
      if(ar[j]==0){ ze=true;  }
      if(ar[j]==1){ on=true; }
      if(ar[j]==2){ ze=true;on=true; break;}

  }

    if(ze==true && on==true){ cout<<"NO"<<endl; f=false; break; }

 if(ze==true){/*cout<<"1 entr"<<endl;*/ s1=s1+"1"; if(ar[x]==-1)ar[x]=1; else{ if(ar[x]!=1)ar[x]=2; } continue; }
  if(on==true){ /*cout<<"0 entr"<<endl;*/s1=s1+"0" ;if(ar[x]==-1)ar[x]=0; else{ if(ar[x]!=0)ar[x]=2; } continue; }

 }
  //cout<<"hi1"<<endl;
  //cout<<"hi2"<<endl;
  if(f){ cout<<"YES\n"<<s1<<endl;  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n;
	string s;
	cin >> n >> s;

	vector<int> maxdp(26);
	vector<int> dp(n, 1);
	for (int i = 0; i < n; ++i) {
		for (int c = 25; c > s[i] - 'a'; --c) {
			dp[i] = max(dp[i], maxdp[c] + 1);
		}
		maxdp[s[i] - 'a'] =  max(maxdp[s[i] - 'a'], dp[i]);
	}
	int maxx=*max_element(maxdp.begin(), maxdp.end());
	if(maxx>2) cout<<"NO"<<endl;
	else {cout <<"YES"<< endl;
	    for (int i = 0; i < n; ++i) cout << dp[i]-1;
	}
	cout << endl;

	return 0;
}

#include <iostream>
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    ios
 int n,max,z=0;
 string s;
 cin>>n;
 cin>>s;
 if(n>2)
 {
     for(int j=0;j<n-2;j++)
     {
         for(int u=j;u<n-1;u++)
         {
         if((s[j]-'0')>(s[u+1]-'0'))
         {for(int x=u+1;x<n-1;x++)
         {
             if((s[u+1]-'0')>(s[x+1]-'0'))
            { z=1;
             break;}
         }
         }
         }
     }
     if(z==1)
     {
         cout<<"NO";

     }
     else
     {
     cout<<"YES\n";
     max=s[0]-'0';

     for(int i=0;i<n;i++)
     {

         if((s[i]-'0')>=max)
         {
             cout<<"0";

             max=s[i]-'0';
         }
         else
         {
             cout<<"1";

         }
     }
     }

 }
 else
 {
     cout<<"YES"<<"\n";
     if(n==2)
     {
         cout<<"01";
     }
     else
     cout<<"0";
 }

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define All(x) x.begin() , x.end()
#define mem(aa,x) memset(aa,x,sizeof aa)
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
const int maxn=205;

vi v[maxn];
int ans[maxn];
bool visit[maxn];

bool dfs(int now,bool color){
	//cout<<"test"<<now<<" "<<color<<"\n";

	if(ans[now]==!color) return 0;
	if(visit[now]) return 1;

	ans[now]=color;
	visit[now]=1;

	for(auto i:v[now])
		if(!dfs(i,!color))
			return 0;

	return 1;
}

main(){
	int n;
	string s;
	cin>>n>>s;
	rep(i,0,n-1)
		rep(j,i+1,n-1)
			if(s[i]>s[j]){
				v[i].pb(j);
				v[j].pb(i);
			}
	mem(ans,-1);
	mem(visit,0);

	rep(i,0,n-1){
		if(ans[i]==-1){
			if(!dfs(i,0)){
				puts("NO");
				return 0;
			}
		}
	}

	puts("YES");
	rep(i,0,n-1) cout<<ans[i];
	cout<<"\n";
}

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, mx = 0;
string s;
int mex[256], col[N];

int32_t main()
{
    IOS;
    cin >> n >> s;
    memset(mex, -1, sizeof(mex));
    for(int i = 0; i < n; i++)
    {
        int cur = -1;
        for(char ch = s[i] + 1; ch <= 'z'; ch++)
            cur = max(cur, mex[ch]);
        cur++;
        mex[s[i]] = cur;
        col[i] = cur;
        mx = max(mx, cur + 1);
    }
    if(mx <=2)
    {cout << "YES" << endl;
    for(int i = 0; i < n; i++)
        cout << col[i];
    }
    else{
        cout << "NO";
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;

const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
    #ifdef PC
        freopen("e.in", "r", stdin);
        freopen("e.out", "w", stdout);
    #endif
}

template <typename T>
void scerr(T nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}

int ans[N], pos[N], pos1[N], n;
string s;

int main() {
	data();
	cin >> n >> s;
	string s1 = s;
	cerr << s << '\n';
	for (int i = 1, j, f; i < sz(s); ++i) {
		j = i, f = 1;
		for (int k = 0; k < sz(s); ++k)
			pos1[k] = pos[k];
		string cnt = s1;
		while (cnt[j - 1] > cnt[j]) {
			if (pos1[j] == pos1[j - 1]) {
				f = 0;
				break;
			}
			swap(pos1[j - 1], pos1[j]);
			swap(cnt[j - 1], cnt[j]);
			--j;
		}
		if (!f) {
			for (int k = 0; k < sz(s); ++k)
				pos1[k] = pos[k];
			f = ans[i] = pos1[i] = 1;
			while (cnt[j - 1] > cnt[j]) {
				if (pos1[j] == pos1[j - 1]) {
					f = 0;
					break;
				}
				swap(pos1[j - 1], pos1[j]);
				swap(cnt[j - 1], cnt[j]);
				--j;
			}
			if (!f) {
				printf("NO\n");
				return 0;
			}
			else {
				s1 = cnt;
				for (int k = 0; k < sz(s); ++k)
					pos[k] = pos1[k];
			}
		}
		else {
			s1 = cnt;
			for (int k = 0; k < sz(s); ++k)
				pos[k] = pos1[k];
		}
	}
	printf("YES\n");
	for (int i = 0; i < sz(s); ++i)
		printf("%d", ans[i]);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/

/** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> v[210];
    ll idx = 0;
    rep(i,0,N){
        char max_char = (char)0, pos = -1;
        rep(j,0,idx){
            ll sz = v[j].size();
            if(S[i] >= S[v[j][sz-1]] && max_char < S[v[j][sz-1]]){
                max_char = S[v[j][sz-1]];
                pos = j;
            }
        }
        if(pos == -1){
            v[idx].push_back(i);
            idx++;
        }else{
            v[pos].push_back(i);
        }
    }
    if(idx > 2){
        print("NO");
        return 0;
    }
    map<ll,bool> mp;
    for(auto &e: v[0]) mp[e] = true;
    print("YES");
    rep(i,0,N){
        if(mp[i]) cout << 1;
        else cout << 0;
    }
    cout << endl;

}

/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ln '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
#define cad static_cast<long double>
#define deb(z) cout << "// " << #z << " = " << z << '\n';
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

template<typename... T>
inline void scan(istream&, T&...);
template<typename... T>
inline void scan(ifstream&, T&...);
template<typename... T>
inline void print(ostream&, T&&...);
template<typename... T>
inline void print(ofstream&, T&&...);
template<typename... T>
inline void println(ostream&, T&&...);
template<typename... T>
inline void println(ofstream&, T&&...);

int32_t main() {
	ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

#ifdef _DEBUG
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int n; scan(cin, n);
	pair<char,int> ar[n];
	for (int i = 0; i < n; ++i)
	{
		scan(cin, ar[i].x);
		ar[i].y=-1;
	}

	bool can = true;
	ar[0].y=1;
	for (int i = 1; i < n; ++i)
	{
		// int temp=-1;
		for (int j = i-1; j >= 0; --j)
		{
			if(ar[j].x>ar[i].x) {
				// if(ar[j].y==-1) {
					// pass
				// } else {
					if(ar[j].y==0)
						ar[i].y=1;
					else
						ar[i].y=0;
					break;
				// }
			}
		}
		if(ar[i].y==-1) {
			// if(ar[i-1].y==0)
				// ar[i].y=1;
			// else
				ar[i].y=1;
		}
	}

	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j < i; ++j)
		{
			if(ar[j].x>ar[i].x && ar[j].y==ar[i].y) {
				can=false;
				break;
			}
		}
	}
	if(can) {
		println(cout, "YES");
		for(auto &&i:ar) {cout << i.y;}
		cout  << '\n';
	} else {
		println(cout, "NO");
		// for(auto &&i:ar) {cout << i.y;}
	}

	return 0;
}

template<typename... T>
inline void scan(istream& cin, T&... args) { ((cin >> args), ...); }

template<typename... T>
inline void scan(ifstream& cin, T&... args) { ((cin >> args), ...); }

template<typename... T>
inline void print(ostream& cout, T&&... args) { ((cout << args << ' '), ...); }

template<typename... T>
inline void print(ofstream& cout, T&&... args) { ((cout << args << ' '), ...); }

template<typename... T>
inline void println(ostream& cout, T&&... args) {
	((cout << args << ' '), ...);
	cout << '\n';
}

template<typename... T>
inline void println(ofstream& cout, T&&... args) {
	((cout << args << ' '), ...);
	cout << '\n';
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
	char ans[300];
	int n,a0=0,a1=0;
	int i,flag=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		char p;
		scanf("%c", &p);
		while (p == '\r' || p == '\n')
		{
			scanf("%c", &p);
		}
		if (p >= a0)
		{
			ans[i] = 0;
			a0 = p;
		}
		else if (p >= a1)
		{
			ans[i] = 1;
			a1 = p;
		}
		else
		{
			flag = 1;
		}
	}
	if (flag == 1)
		printf("NO\n");
	else
	{
		printf("YES\n");
		for (i = 0; i < n; i++)
		{
			printf("%d", ans[i]);
		}
		printf("\n");
	}
}

#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const long long N = 200005;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
#define MP make_pair
#define PB push_back
ll n, m, i, j, k, color[N],ans[N];
string a,t;
pair<char, ll> s[N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> a;
	t = a;
	for (i = 0; i < n; i++)
		s[i] = MP(a[i], i);
	ll qanak = 0;
	for (i = 0; i <= 26; i++)
	{
		for (j = 0; j < n; j++)
		{
			ll x = s[j].first - 'a';
			if (x == i)
			{
				if (j == qanak)
					qanak++;
				else
				{
					ll tiv = 0, v = 0;
					/*for (ll l = 0; l < n; l++)
						cout << color[l];
					cout << endl;*/
					ll tiv1 = 0, tiv2 = 0;
					for (ll l = qanak; l < j; l++)
					{
						if (color[l] == 1)
						{
							tiv1=1;
							v = 1;
						}
						if (color[l] == 2)
						{
							tiv2=2;
							v = 2;
						}
						if (tiv1+tiv2 >= 2)
							break;
					}
					tiv = tiv1 + tiv2;
					if (tiv == 2)
					{
						cout << "NO" << endl;
						return 0;
					}
					if (color[j] == 0)
					{
						if (tiv == 0)
						{
							v = 1;
							color[j] = 2;
						}
						if (tiv == 1)
						{
							if (v == 1)
								color[j] = 2;
							else
								color[j] = 1;
						}
						for (ll l = qanak; l < j; l++)
							color[l] = v;
						for (ll l = j; l > qanak; l--)
						{
							swap(s[l], s[l - 1]);
							swap(color[l], color[l - 1]);
						}
						qanak++;
					}
					else
					{
						if (tiv == 0)
						{
							if (color[j] == 1)
								v = 2;
							else
								v = 1;
						}
						if (tiv == 1)
						{
							if (color[j] == v)
							{
								cout << "NO" << endl;
								return 0;
							}
						}
						for (ll l = qanak; l < j; l++)
							color[l] = v;
						for (ll l = j; l > qanak; l--)
						{
							swap(s[l], s[l - 1]);
							swap(color[l], color[l - 1]);
						}
						qanak++;
					}
				}
			}
		}
	}
	cout << "YES" << endl;
	ll ban = 0;
	for (i = 0; i < n; i++)
	{
		ans[s[i].second] = color[i]%2;
	}
	for (i = 0; i < n; i++)
		cout << ans[i];
	cout << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d", &(x))
#define sclld(x) scanf("%lld", &(x))
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define MT make_tuple
#define MP make_pair
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef long long ll;
typedef pair<int, int> ii;
const double pi = 2*acos(0);
const int oo = 2e9;

const int N = 205;
const int AL = 27;
int n;
int dp[N][AL][AL];
bool path[N][AL][AL];
string s;
bool solve(int i = 1, int z = 0, int o = 0);

int main()
{
    sc(n);
    s.assign(n, ' ');
    for (int i = 0; i < n; i++)
        scanf(" %c", &s[i]);

    memset(dp, -1, sizeof(dp));
    if (solve())
    {
        puts("YES");
        int z = 0, o = 0;
        for (int i = 1; i <= n; i++)
        {
            if (path[i][z][o])
                printf("1"), o = s[i-1]-'a'+1;
            else
                printf("0"), z = s[i-1]-'a'+1;
        }
        printf("\n");
    }
    else
        puts("NO");
    return 0;
}

bool solve(int i, int z, int o)
{
    if (i == n+1)
        return true;
    int& ret = dp[i][z][o];
    if (~ret)
        return ret;
    ret = false;
    if ((o == 0 || s[i-1] >= o-1+'a') && solve(i+1, z, s[i-1] - 'a' + 1))
        ret = true, path[i][z][o] = 1;
    if ((z == 0 || s[i-1] >= z-1+'a') && solve(i+1, s[i-1] - 'a' + 1, o))
        ret = true, path[i][z][o] = 0;
    return ret;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q,aa,dsasd,sds;

    string str;

    bool flag=true;

    cin>>n;

    cin>>str;

    vector<ll>v[200];

    for(i=0; i<n; i++)
    {
        v[str[i]].eb(i);
    }

    ll ara[n+1]= {-1},bra[n+1];
//    vector<ll>v[200];

memset(ara,-1,sizeof(ara));

    for(i=0; i<n; i++)
    {
       if(ara[i]==-1)
        {ara[i]=0;

       for(j=i+1; j<n; j++)
       {
           if(str[i]==str[j])
            ara[j]=ara[i];

           else if(str[j]<str[i])
           {
               if(ara[i]==0)ara[j]=1;

               else ara[j]=0;
           }

       }
        }
    }

    string btr=str;

    sort(vll(btr));

  for(i=0; i<n; i++)
    bra[i]=ara[i];

    flag=true;

   for(i=1; i<n; i++)
   {
       j=i;

      // bug;
       while(j>=1 && str[j]<str[j-1] && bra[j]!=bra[j-1])
       {
           swap(str[j],str[j-1]);
            swap(bra[j],bra[j-1]);

            j--;
       }
   }

   //cout<<str<<endl;

    if(str==btr)
    {
        cout<<"YES"<<endl;
        for(i=0; i<n; i++)
            cout<<ara[i];

        cout<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {

	    int n;
	    cin>>n;

	    string s;
	    cin>>s;
	    int a[n];
	    a[0] = 0;
	    int max = s[0];
	    int change[26];
	    for(int i=0;i<26;i++){
	        change[i] = 0;
	    }
	    for(int i = 0;i<n-1;i++){
	        if(s[i+1]>max){
	            max = s[i+1];

	        }
	        if(s[i+1]<max){
	            a[i+1] = 1;
	            if(change[s[i+1]-97] ==0){
	                change[s[i+1]-97] = i+1;

	            }
	        }
	        else if(s[i] >s[i+1]){
	            a[i+1] = 1;
	             if(change[s[i+1]-97] ==0){
	                change[s[i+1]-97] = i+1;

	            }

	        }
	        else if(a[i] == 1 && s[i]==s[i+1]){
	            a[i+1] = 1;
	             if(change[s[i+1]-97] ==0){
	                change[s[i+1]-97] = i+1;

	            }

	        }
	        /*else if(s[i+1]<max){
	            a[i+1] = 1;
	        }*/

	        else{
	            a[i+1] = 0;
	        }

	    }

	    int flag = 0;
	    for(int i=0;i<n-1;i++){
	        if(a[i]==1){
	            if(s[i]>s[i+1]){
	                cout<<"NO"<<endl;
	                flag =1;
	                break;
	            }
	        }
	    }
	    if(flag==0){
	    for(int i=0;i<n;i++){
	        if(a[i]==1){
	            for(int j = s[i]-97+1;j<26;j++){
	                if(change[j]!=0){
	                    if(change[j]<i){
	                        cout<<"NO"<<endl;
	                        flag = 1;
	                        break;
	                    }
	                }
	            }
	            if(flag ==1){
	                break;
	            }
	        }

	    }
	    }
	    if(flag==0){
	    cout<<"YES"<<endl;
	    for(int i=0;i<n;i++){
	        cout<<a[i];
	    }
	    cout<<endl;

	    }

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
char str[210],ch0,ch1,ans[210];
int main()
{
	int n;
	cin>>n>>str;
	for(int i=0;i<n;i++)
	{
		if(str[i]>=ch0)
		{
			ch0=str[i];
			ans[i]='0';
		}
		else if(str[i]>=ch1)
		{
			ch1=str[i];
			ans[i]='1';
		}
		else
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	puts(ans);
	return 0;
}

//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define ps(a) push_back(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1;while(b){if(b&1)ans=ans*a%mod;
a=a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
//
const int maxm=2e5+5;
char s[maxm];
int ans[maxm];
int d[33];//每种字符的颜色最大值
signed main(){
    int n;
    cin>>n;
    scanf("%s",s+1);
    int cnt=0;
    for(int i=1;i<=n;i++){
        int ma=0;
        for(int j=s[i]-'a'+1;j<26;j++){
            ma=max(ma,d[j]);
        }
        d[s[i]-'a']=max(d[s[i]-'a'],ma+1);
        ans[i]=max(d[s[i]-'a'],ma+1);
        cnt=max(ans[i],cnt);
    }
    if(cnt<=2){
        cout<<"YES"<<endl;
        for(int i=1;i<=n;i++){
            cout<<ans[i]-1;
        }
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2002;
char s[N];
int n,col[N],i,j,c0,c1;
void init(){
    scanf("%d%s",&n,s+1);
}
void work(){
    for(i=1;i<=n;i++){
        c0=c1=0;
        for(j=1;j<i;j++)
            if(s[j]>s[i]){
                if(col[j]==1)
                    c1=1;
                else
                    c0=1;
            }
        if(c1&&c0){
            printf("NO");
            return;
        }
        if(c0)
            col[i]=1;
        else
            col[i]=0;
    }
    printf("YES\n");
    for(i=1;i<=n;i++)
        printf("%d",col[i]);
}
int main(){
    init();
    work();
    return 0;
}

/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n;
string s,ans;
char x='a',y='a';
int32_t main(){
CODE_START;
cin>>n;
cin>>s;
for(ll i=0;i<n;i++)
{
    if(s[i]>=x){
        ans=ans+'0';
        x=s[i];
    }else if(s[i]>=y){
    ans=ans+'1';
    y=s[i];
    }else rc("NO");
}
cout<<"YES"<<endl;
cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 1<<29;

int main(){
    int T = 1;
    //cin >> T;
    while (T--){
        int n;
        string s;
        vector<int> col;
        int max = 0;
        bool ans = true;
        cin >> n >> s;
        for (int i = 0; i<n; i++){
            if ((int) s[i] >= max){
                max = (int) s[i];
            } else {
                col.push_back(i);
            }
        }
        if (col.size() == 0){
            cout << "YES" << endl;
            string z(n,'0');
            cout << z << endl;
            continue;
        }
        max = (int) s[col[0]];
        for (int i = 1; i<col.size(); i++){
            if (max > (int) s[col[i]]){
                ans = false;
                break;
            }
            max = (int) s[col[i]];
        }
        if (ans){
            cout << "YES" << endl;
            string z(n,'0');
            for (int i = 0; i<col.size(); i++) z[col[i]] = '1';
            cout << z << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

//apigs property
//Happiness can be found, even in the darkest of times, if one only remembers to turn on the light
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define md (s + e) / 2
#define mid (l + r) / 2
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define lx node * 2
#define rx node * 2 + 1
using namespace std;
typedef long long ll;
ll q, dp[105][100005], a[555555] , b[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
void solve(){
	cin >> n;
	string s , t;
	cin >> s;
	t = "";
	char a1 = 'a' , a2 = 'a';
	for(ll i = 0 ; i < n ; i++){
		if(s[i] >= a1){
			a[i] = 0;
			a1 = s[i];
		}
		else if(s[i] >= a2){
			a[i] = 1;
			a2 = s[i];
		}
		else return void(cout << "NO\n" << endl);
	}
	cout << "YES\n";
	for(ll i = 0 ; i < n ; i++) cout << a[i];
}
int main(){
    fast ;
	// cin >> q;
    q = 1;
    while(q--){
    	solve();
	}
}

#include <bits/stdc++.h>
using namespace std;

int main()
{

    int n;
    string s;
    cin>>n;
    cin>>s;
    vector<int> color(n, -1);
    bool poss = true;
    for (int i=0;i<n && poss;i++){
        if (color[i]==-1){
            color[i] = 0;
        }
        for (int j=i+1;j<n && poss;j++){
            if (s[j]>=s[i]){
                continue;
            }
            if (color[j]==color[i]){
                poss = false;
                break;
            }
            else{
                color[j] = color[i]^1;
            }
        }
    }
    if (poss){
        cout<<"YES"<<endl;
        string ans = "";
        for (int j=0;j<n;j++){
            ans += to_string(color[j]);
        }
        cout<<ans<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define sh 3500
#define pb push_back
#define ll long long

int tr[4*27+1]={0};
void update(int node,int st,int end,int id,int val)
{
    if(st==end)
    {
        tr[node]=val;
        return ;
    }
    int mid=(st+end)/2;
    if(id<=mid)
    update(2*node,st,mid,id,val);
    else
    update(2*node+1,mid+1,end,id,val);
    tr[node]=max(tr[2*node],tr[2*node+1]);
}
int q(int node,int st,int end,int l,int r)
{
    if(l>r||st>r||l>end)
    return 0;
    if(st>=l&&end<=r)
    return tr[node];
    int mid=(st+end)/2;
    return (max(q(2*node,st,mid,l,r),q(2*node+1,mid+1,end,l,r)));

}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    int mx=0;
    int dp[n+1];
    int next[n+1];
    memset(dp,-1,sizeof(dp));
    memset(next,-1,sizeof(next));
    dp[0]=1;
    update(1,1,26,s[0]-'a'+1,dp[0]);
    for(i=1;i<n;i++)
    {
        dp[i]=q(1,1,26,s[i]+2-'a',26)+1;
        update(1,1,26,s[i]-'a'+1,dp[i]);
        mx=max(mx,dp[i]);
    }
    if(mx>2)
    	cout<<"NO";
    else
    {
    	cout<<"YES\n";
    	for(i=0;i<n;i++)
	    cout<<dp[i]-1;
    }
    //cout<<mx<<endl;

    // for(i=0;i<n;i++)
    // cout<<i<<" "<<s[i]<<" "<<dp[i]<<endl;
    // cout<<endl;
}

// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void ckmax(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
inline void ckmin(T &a, T b) {
  if (a > b) a = b;
}

const int N = 205;
struct ele {
  int le, id;
  friend bool operator < (const ele &a, const ele &b) {
    if (a.le != b.le) return a.le < b.le;
    else return a.id < b.id;
  }
} a[N];
char s[N];
int col[N], n;

int main() {
  scanf("%d%s", &n, s + 1);
  mset(col, -1);
  for (rint i = 1; i <= n; i++) {
    if (col[i] == -1) col[i] = 0;
    for (rint j = i + 1; j <= n; j++) {
      if (s[i] > s[j]) {
        if (col[j] == -1) col[j] = col[i] ^ 1;
        else if (col[j] == col[i]) {
          puts("NO"); exit(0);
        }
      }
    }
  }
  puts("YES");
  for (rint i = 1; i <= n; i++) printf("%d", col[i]);
  puts("");
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define Mod 1000000007

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

void input_array(vll &A){
    for(int i = 0; i < A.size(); i++)
        cin>>A[i];
}

int main(){
    int n;
    cin>>n;

    string s;
    cin>>s;

    vi color(n, 0);
    int i = 0;
    vvi count(26, vi(2, 0));
    bool flag = false;

    while(i < n){
        char c = s[i];
        color[i] = 0;
        count[s[i] - 'a'][0] = 1;
        i++;
        while(i < n && c > s[i]){
            color[i] = 1;
            count[s[i] - 'a'][1] = 1;
            bool f0 = false, f1 = false;
            for(int j = s[i] - 'a' + 1; j < 26; j++){
                if(count[j][0] == 1)
                    f0 = true;
                if(count[j][1] == 1)
                    f1 = true;
                if(f0 && f1){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
            i++;
        }
        if(flag) break;
    }

    if(flag) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        for(auto it: color) cout<<it;
        cout<<endl;
    }

    return 0;
}

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<bitset>
#include<cstdio>
#include<string>
#include<time.h>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int N=2e5+5;
char a[N];
int an[N];
int main()
{
	int n;
	char c=0,s=0;
	scanf("%d%s",&n,a);
	for(int i=0;i<n;i++)
	{
		if(c<=a[i])
		{
			c=a[i];
			an[i]=0;
		}
		else if(s<=a[i])
		{
			s=a[i];
			an[i]=1;
		}
		else
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES\n");
	for(int i=0;i<n;i++)
		printf("%d",an[i]);
}

#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef double DO;
typedef long long INT;
typedef pair<int,int> pii;
typedef pair<pii,int> pi3;
template<typename T, typename U> inline void smin(T &a, const U &b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, const U &b) {if(a<b) a=b;}
char a[300];
int fl[300];
vector <int> adj[300];
void dfs(int u,int fa=0){
	for(int v:adj[u]) if(v!=fa){
		if(fl[v]) {
			if(fl[v]!=3-fl[u]){
				puts("NO");
				exit(0);
			}
			continue;
		}
		fl[v]=3-fl[u];
		dfs(v,u);
	}
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	scanf("%d",&n);
	scanf("%s",a+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			if(a[i]<a[j]) adj[i].pb(j),adj[j].pb(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(fl[i]) continue;
		fl[i]=1;
		dfs(i);
	}
	puts("YES");
	for(int i=1;i<=n;i++) printf("%d",fl[i]%2);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define s second
#define f first
#define MOD 998244353
#define lp(i,n) for(int i = 0;i < n;++i)
#define sz(x) ((int)(x).size())

typedef  long long ll;
typedef pair<ll , ll> pii;
typedef  double ld;
typedef unsigned long long ull ;
static const int OO = 0x3f3f3f3f , N =2*1e2+ 10 ;
static const long long OOL = 1e15+1LL ;

int dx[] = {1 , 1 , 2 , 2 , 3 , 3 };
int dy[] = {2 , 3 , 1 , 3 , 1 , 2 };

int n;
string s,ans;

bool flag=true;

int main() {
    cin >> n>>s;
    int l0='a',l1='a';
    lp(i,n){
        if(s[i]>=l0)ans+='0',l0=s[i];
        else if(s[i]>=l1)l1=s[i],ans+='1';
        else {flag=false;break;}
    }
    cout << (flag?"YES":"NO")<<endl;
    if(flag)cout <<ans;

}

#include <iostream>

using namespace std;
char v[202];
char v1[202];
int sol[202];
int main()
{
    int n,cnt=0,a,b,c,d,i1=0,i2=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        a=s[i];
            d=v[i1-1];
            c=v1[i2-1];
            if(d>a)
            {
                if(c>a)
                {
                    cout<<"NO";
                return 0;
                }

                else
                {
                    sol[i]=1;
                v1[i2]=s[i];
                i2++;
                }
            }
            else
            {
                sol[i]=0;
                v[i1]=s[i];
                i1++;
            }

    }
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        cout<<sol[i];
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
/*long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}*/

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	string s; cin>>s;
	vector<int> vec(n);
	vector<int> kactane(30, 0);
	vector<int> harfmax(30, 0);
	int res = 0;
	for(int i = 0; i < n; i++){
		int cnt = 0;
		kactane[s[i] - 'a']++;
		for(int u = s[i] - 'a' + 1; u <= 'z' - 'a'; u++){
			if(kactane[u]){
				cnt = max(cnt, harfmax[u]);
			}
		}
		//cnt++;
		harfmax[s[i] - 'a'] = max(harfmax[s[i] - 'a'], cnt+1);
		vec[i] = cnt;
		res = max(res, vec[i]);
		if(res > 1){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n";
	for(auto& x: vec) cout<<x;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 0,flag = 0;
    for(int i=n-1;i>0;i--){
        cnt = 0;
        //cout<<(int)(s[i])<<" ";
        for(int j=i-1;j>=0;j--){
            //cout<<(int)(s[j])<<" ";
            if( (int)(s[j]) > (int)(s[i]) ){
                cnt++;
                //int temp = 1+(int)(s[j]);
                for(int k=j-1;k>=0;k--){
                    if((int)s[k] > (int)(s[j])){
                        flag = 1;
                        break;
                    }
                }
                if(flag){
                    break;
                }
            }
        }
    }
    if(flag){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    int a[n] ;
    a[0] = 0;
    int lc = (int)s[0];
    int lt = 0;
    for(int i=1;i<n;i++){
        if( (int)s[i] < lc ){
            a[i] = 1 - lt;
        }
        else{
            a[i] = 0;
            lt = 0;
            lc = (int)s[i];
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i];
    }
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>,
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif

	long int n;
	cin>>n;
	string s;
	cin>>s;

	for(long int i = 0;i < n; i++){
		for(long int j = i; j < n;j++){
			for(long int k = j + 1;k < n; k++){
				if(s[j] < s[i] && (s[k] < s[j]) && (s[k] < s[i])){
					cout<<"NO";
					return 0;
				}
			}
		}
	}

    cout<<"YES"<<endl;

    char maxe = 'a';
    vector<long int> v(n);
    for(long int i = 0; i < n; i++){
    	if(s[i] >= maxe)
    		v[i] = 1;
    	maxe = max(maxe,s[i]);
    }

    for(auto i : v){
    	cout<<i;
    }
   return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define int long long
const int MAXN=3e6;
int q;
string s,t,z;
int m,n,k;
vector<int> vertex[MAXN];
int ok=1;
int vitri[MAXN];
int cnt;
int check[MAXN];
int po[MAXN];
void dfs(int x, int color, int cnt){
    po[x]=cnt;
    check[x]=color;
    for(int i=0;i<vertex[x].size();i++){
        if(check[vertex[x][i]]==0){
            dfs(vertex[x][i],3-color,cnt+1);
        }
        else{
            if((po[vertex[x][i]]-po[x])%2==0){
                ok=0;
            }
        }
    }
}
signed main(){
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    cin>>s;
    ok=1;
    for(int i=0;i<n;i++){
        vitri[i]=i;
    }
    for(int j=1;j<=20000;j++){
        for(int i=1;i<n;i++){
            if(s[i]<s[i-1]){
                char x;
                x=s[i];
                s[i]=s[i-1];
                s[i-1]=x;
                k=vitri[i];
                vitri[i]=vitri[i-1];
                vitri[i-1]=k;
                vertex[vitri[i]].push_back(vitri[i-1]);
            }
        }
    }
    for(int i=0;i<n;i++){
        if(check[i]==0)dfs(i,1,1);
    }
    if(ok==0){
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<"\n";
    for(int i=0;i<n;i++){
        cout<<check[i]-1;
    }
    return 0;
}

/*
 * @Author: cy
 * @Date: 2020-02-25 15:40:28
 * @LastEditors: cy
 * @LastEditTime: 2020-02-25 16:33:16
 * @FilePath: \dp\cf_dp\3.cpp
 * @Problem:  String Coloring (easy version) *1800
 * @Link:  https://codeforces.com/problemset/problem/1296/E1
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int num=1e5+3;
char s[220];
int vs[220];
int main()
{
    int len;
    scanf("%d%s",&len,s);
    int f=0;
    for(int i=0;i<len;i++)
    {
        for(int j=i+1;j<len;j++)
        {
            if(s[j]>=s[i]) continue;
            for(int k=j+1;k<len;k++)
            {
                if(s[k]<s[j]) f=1;
            }
        }
        if(f) break;
    }
    if(f) { printf("NO"); return 0;}
    for(int i=0;i<len;i++)
    {
        f=0;
        for(int j=i+1;j<len;j++)
        if(s[j]<s[i]) {f=1;break;}
        vs[i]=f;
    }
    printf("YES\n");
    for(int i=0;i<len;i++)
    printf("%d",vs[i]);
    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS

    ll n, i;
    cin >> n;

    string s;
    cin >> s;

    string res = "";
    char last0 = 'a';
    char last1 = 'a';

    for(i = 0; i < n; i++)
    {
        if(s[i] >= last0)
        {
            res += "0";
            last0 = s[i];
        }
        else if(s[i] >= last1)
        {
            res += "1";
            last1 = s[i];
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    cout<<res<<endl;

    return 0;
}

/*input
7
cnaaaaaabbbbbccccdddddddddddddeeeeeeeee
*/
#include<bits/stdc++.h>
#define fn(i,n) for(int i=0;i<n;i++)
#define fn1(i,n) for(int i=1;i<=n;i++)
#define ll long long int
#define mod 1000000007
using namespace std;
int a[300],check[300],count1;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;cin>>n;
string s;
cin>>s;
bool flag=1;
n=s.size();
fn(i,300)a[i]=1;
check[0]=1;
for(int i=0;i<n;i++)
{
    for(int j=0;j<n;j++)
    {
        if(i<j&&s[i]>s[j])
        {
            //cout<<i<<" "<<j<<endl;
            if(check[i])
            {
                if(check[j])
                {
                    if(a[i]==a[j])flag=0;
                }
                else
                {
                    check[j]=1;
                    if(a[i]==1)a[j]=2;else a[j]=1;
                }
            }
            else
            {
                check[i]=1;
                if(check[j])
                {
                    if(a[j]==1)a[i]=2;else a[i]=1;
                }
                else
                {
                    check[j]=1;
                    a[i]=1;a[j]=2;
                }
            }
        }
    }
}
if(flag)
{
    cout<<"YES"<<endl;
    fn(i,n)cout<<a[i]-1;
}
else
cout<<"NO"<<endl;
}

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, mx = 0;
string s;
int mex[256], col[N];

int32_t main()
{
    IOS;
    cin >> n >> s;
    memset(mex, -1, sizeof(mex));
    for(int i = 0; i < n; i++)
    {
        int cur = -1;
        for(char ch = s[i] + 1; ch <= 'z'; ch++)
            cur = max(cur, mex[ch]);
        cur++;
        mex[s[i]] = cur;
        col[i] = cur;
        mx = max(mx, cur + 1);
    }
    if(mx <=2)
    {cout << "YES" << endl;
    for(int i = 0; i < n; i++)
        cout << col[i];
    }
    else{
        cout << "NO";
    }
    return 0;
}

#include<bits/stdc++.h>

#define ll  long long int
#define ld  long double
#define MAX 1000001
#define MOD 1000000007
#define pi  3.14159265358979323846264338
#define mp  make_pair
#define pb  push_back
#define pll pair<ll,ll>
#define vl  vector<ll>
#define vi  vector<int>
#define vs  vector<string>
#define vc  vector<char>
#define fst first
#define sec second
#define foi(i, a, b)   for(ll i = a; i<b;i++)
#define fod(i, a, b)   for(ll i = a;i>=b;i--)
#define all(v)         (v).begin(), (v).end()
#define max3(a, b, c)  max(max(a,b), c)
#define min3(a, b, c)  min(min(a,b), c)
#define ump  unordered_map<ll,ll>
#define us   unordered_set<ll>
#define nl  "\n"
#define INF  (ll)1e18
#define s(v) (ll)(v).size()
#define e(v) (v).empty

using namespace std;

ll gcd(ll a,ll b) { if (a==0) return b; return gcd(b%a,a);}

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    char c;
    vi clr(n,0);
    int flag = 0;
    int l = 0;
    int r = n-1;
    foi(i,1,n){
        c = s[i];
        int j;
        for(j=i-1;j>=0;j--){
            if(s[j]>c){
                if(j<l){
                    flag = 1;
                    cout<<"NO"<<"\n";
                    break;
                }
                s[j+1] = s[j];

            }else{
                break;
            }
        }
        if(flag){
            break;
        }
        if(i!=j+1){
            s[j+1] = c;
            l = j+2;
            clr[i]=1;
        }

    }
    if(!flag){
        cout<<"YES"<<"\n";
        foi(i,0,n){
            cout<<clr[i];
        }
        cout<<"\n";
    }
}
int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

#include <bits/stdc++.h>

typedef long long ll;
const int INFI = (1 << 29);
const ll INFL = (1LL << 62);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) int(x.size())
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define forn(tourBina, n) for(ll tourBina = 0; tourBina < n; tourBina++)
#define fore(tourBina, l, r) for(ll tourBina = l; tourBina <= r; tourBina++)
#define DBG(x) cerr << #x << " = " << x << endl

using namespace std;

void solve()
{
    ll n;
    string s;

    cin >> n >> s;

    vector < pair < char, ll > > v(n);
    vector < ll > c(n, -1);

    forn(i, n)
        v[i] = {s[i], i};

    sort(all(s));

    forn(i, n)
    {
        fore(j, i, (n - 1))
        {
            if(v[j].fi == s[i])
            {
                ll color = -1;

                fore(k, i, (j - 1))
                    if(c[v[k].se] != -1)
                        color = c[v[k].se];

                if(color == -1)
                {
                    fore(k, i, (j - 1))
                        c[v[k].se] = 0;

                    if(c[v[j].se] == -1)
                        c[v[j].se] = 1;
                }
                else
                {
                    fore(k, i, (j - 1))
                        c[v[k].se] = color;

                    if(c[v[j].se] == -1)
                        c[v[j].se] = !color;
                }

                for(ll k = j; k > i; k--)
                    if(c[v[k - 1].se] != c[v[k].se])
                        swap(v[k - 1], v[k]);

                if(s[i] != v[i].fi)
                {
                    cout << "NO\n";

                    return;
                }

                break;
            }
        }
    }

    cout << "YES\n";
    forn(i, n)
        cout << c[i];
    cout << "\n";
}

int main()
{
	FIO;

	#ifdef tourBina
		///freopen("input.in", "r", stdin);
	#endif

    solve();

	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

string s;

int f[210],n;

bool flag;

int main()
{
  cin>>n>>s;
  f[0]=1;
  for(int i=1;i<n;i++)
  {
    f[i]=1;
    for(int j=0;j<i;j++)if(s[j]>s[i]) f[i]=max(f[i],f[j]+1);
    if(f[i]>2)
    {
      flag=true;
      break;
    }
  }
  if(flag)
  {
    cout<<"NO"<<endl;
    return 0;
  }
  cout << "YES" <<  endl;
  for(int i=0;i<n;i++)cout<<f[i]-1;
  cout<<endl;
}

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define fast_az_fuk ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mapll map<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast_az_fuk
    ll n; cin>>n; string s; cin>>s;
    ll maxDp[26]; ms(maxDp,0);
    ll dp[n]; dp[0]=1; maxDp[s[0]-'a']=1;
    for(ll i=1;i<n;i++){
        dp[i]=1;
        for(ll c=s[i]-'a'+1;c<26;c++) dp[i]=max(dp[i],maxDp[c]+1);
        maxDp[s[i]-'a']=max(maxDp[s[i]-'a'],dp[i]);
    }
    ll maxLen=0;
    for(ll i=0;i<n;i++) maxLen=max(maxLen,dp[i]);
    if(maxLen>2) {cout<<"NO\n"; return 0;}
    cout<<"YES\n";
    for(ll i=0;i<n;i++) cout<<dp[i]-1;
    return 0;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000;
int vis[maxn];
char s[maxn], t[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n >> s;
    for(int i = 0;i < n;i++) vis[i] = -1, t[i] = s[i];
    sort(t, t + n);
    for(int i = 0;i < n;i++)
    {
        if(vis[i] == -1){
            vis[i] = 0;
        }

            for(int j = i + 1;j < n;j++)
            {
                if(s[j] < s[i]) vis[j] = (vis[i] ^ 1);
            }

    }
    bool flag = false;
    for(int i = 0;i < n;i++)
        for(int j = i + 1;j < n;j++){
         if(s[i] > s[j] && vis[i] == vis[j])  flag = true;
    }
    if(flag)  cout << "NO" << endl ;
	else
	{
		cout << "YES" << endl;
		for(int i = 0;i < n;i++) cout << vis[i];
		cout << endl;
	}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define All(x) x.begin() , x.end()
#define mem(aa,x) memset(aa,x,sizeof aa)
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
const int maxn=205;

vi v[maxn];
int ans[maxn];
bool visit[maxn];

bool dfs(int now,bool color){
	//cout<<"test"<<now<<" "<<color<<"\n";

	if(ans[now]==!color) return 0;
	if(visit[now]) return 1;

	ans[now]=color;
	visit[now]=1;

	for(auto i:v[now])
		if(!dfs(i,!color))
			return 0;

	return 1;
}

main(){
	int n;
	string s;
	cin>>n>>s;
	rep(i,0,n-1)
		rep(j,i+1,n-1)
			if(s[i]>s[j]){
				v[i].pb(j);
				v[j].pb(i);
			}
	mem(ans,-1);
	mem(visit,0);

	rep(i,0,n-1){
		if(ans[i]==-1){
			if(!dfs(i,0)){
				puts("NO");
				return 0;
			}
		}
	}

	puts("YES");
	rep(i,0,n-1) cout<<ans[i];
	cout<<"\n";
}

#include<bits/stdc++.h>
using namespace std;

bool color[205];

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<char> V;
  for(int i=1,j=0;i<n;i++){
    if(s[i]>=s[j])
      j=i;
    else
      V.push_back(s[i]),color[i]=true;
  }
  bool flag=true;
  for(int i=1;i<(int)V.size();i++){
    if(V[i]<V[i-1])
      flag=false;
  }
  if(flag){
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++){
      if(color[i])
	printf("1");
      else
	printf("0");
    }
  }
   else
    cout<<"NO"<<endl;
}

/** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> v[210];
    ll idx = 0;
    rep(i,0,N){
        char max_char = (char)0, pos = -1;
        rep(j,0,idx){
            ll sz = v[j].size();
            if(S[i] >= S[v[j][sz-1]] && max_char < S[v[j][sz-1]]){
                max_char = S[v[j][sz-1]];
                pos = j;
            }
        }
        if(pos == -1){
            v[idx].push_back(i);
            idx++;
        }else{
            v[pos].push_back(i);
        }
    }
    if(idx > 2){
        print("NO");
        return 0;
    }
    map<ll,bool> mp;
    for(auto &e: v[0]) mp[e] = true;
    print("YES");
    rep(i,0,N){
        if(mp[i]) cout << 1;
        else cout << 0;
    }
    cout << endl;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   int n,i,j,h=0;
   cin>>n>>s;
   vector<int> a(n),b(n);
   char ch;
   for(i=1;i<n;i++)
     {
          ch=s[i];
          if(s[i]<s[i-1])
            {
                  a[i]=b[i]=1;
                  for(j=i;j>0,s[j-1]>ch;j--)
                     {
                         if(a[j] && j!=i)
                           h=1;
                         s[j]=s[j-1];
                     }
                 if(a[j] && j!=i)
                   h=1;
                 a[j]=1;
                 s[j]=ch;
                 a[i]=0;
            }
     }
    if(h==1)
      cout<<"NO\n";
    else
      {
          cout<<"YES\n";
          for(int i=0;i<n;i++)
             cout<<b[i];
          cout<<endl;
      }
}

#include <bits/stdc++.h>
using namespace std;
const int N=205;
int n;
int ans[N];
char str[N];
int main(){
	scanf("%d",&n);
	scanf("%s",str+1);
	for (register int i=1; i<=n; ++i)
	for (register int j=i+1; j<=n; ++j)
	for (register int k=j+1; k<=n; ++k)
	if (str[i]>str[j] && str[j]>str[k])
	{
		puts("NO");
		return 0;
	}
	ans[1]=0;
	for (register int i=2; i<=n; ++i)
	{
		for (register int j=1; j<i; ++j)
		if (str[j]>str[i]) {ans[i]=ans[j]^1; break;}
	}
	puts("YES");
	for (register int i=1; i<=n; ++i) printf("%d",ans[i]);
return 0;
}

#include <iostream>
using namespace std;
string an[2]= {"NO","YES"};
int v[201];
int main() {
        string s,sx;
        bool ans=1;
        int n;
        cin>>n>>s;
        sx=s;
        for(int i=0; i<s.size()-1; i++) {
                for(int j=i+1; j<s.size(); j++) {
                        if(s[i]>s[j]) {
                                if(!(v[i]&&v[j])) {
                                        if(v[i]==v[j]&&v[i]==0) {
                                                v[i]=-1;
                                                v[j]=1;
                                        } else if(v[i]&&!v[j])
                                                v[j]=0-v[i];
                                        else if(v[j]&&!v[i])
                                                v[i]=0-v[j];
                                } else {
                                        if(v[i]==v[j])
                                                ans=0;
                                }
                        }
                }
        }
        cout<<an[ans];
        if(ans==1) {
                cout<<'\n';
                for(int i=0; i<n; i++)
                        if(v[i]==-1)
                                cout<<0;
                        else
                                cout<<v[i];
        }
        return 0;
}

#include<bits/stdc++.h>
					using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
	using namespace std;
                    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
                    #define pb push_back
                    #define ff first
                    #define ss second
                    #define sz size()
                    #define mp make_pair
                    #define int long long int
                    #define double long double
                    #define bp __builtin_popcountll
                    #define FOR(i,a,b) for(int i=a;i<b;i++)
                    #define ROR(i,a,b) for(int i=a;i>=b;i--)

                    const int MAXN=1e7+7;
                    const int MA=5e3+5;

                               int gcd(int a, int b)
            {
                if (b == 0)
                    return a;
                return gcd(b, a % b);

            }

            int chk(char a)
            {
              if(a=='L')
              return 10;
              if(a=='R')
              return -10;
              if(a=='U')
              return 1;

              return -1;
            }

int32_t main()
{
  FAST
  int t;
  cin>>t;
  char arr[t+10];
  int arr2[t]={0},arr3[t]={0};
  cin>>arr;
  int k=1;
  arr2[0]=arr3[0]=-1;
  for(int i=1;i<t&&k==1;i++)
  {
   for(int j=i;j>0&&k==1;j--)
   {
     if(arr[j]>=arr[j-1])
     {
     if(arr2[j]==0)
     {
      //  if(arr[j]==arr[j-1])
      arr2[j]=arr3[j]=arr2[j-1];

     break;
     }
     }
     if(arr[j-1]>arr[j])
     {

      if(arr2[j-1]==-1&&arr2[j]==0)
      {

      arr2[j]=1;
      arr3[j]=1;
      swap(arr2[j],arr2[j-1]);
      swap(arr[j-1],arr[j]);
      }
      else if(arr2[j]==0)
      {
        arr2[j]=-1;
        arr3[j]=-1;
        swap(arr2[j],arr2[j-1]);
        swap(arr[j-1],arr[j]);
      }
      else
      {
        if(arr2[j-1]==arr2[j])
        {
           // cout<<arr[j-1]<<arr[j]<<"\n";
          k=0;
          break;
        }
        else
        {
          swap(arr2[j],arr2[j-1]);
          swap(arr[j-1],arr[j]);
        }

      }

     }

   }
  }
  if(k==0)
  {
    cout<<"NO\n";
  }
  else
  {
    cout<<"YES\n";
    for(int i=0;i<t;i++)
     if(arr3[i]==1)
    cout<<arr3[i];
        else
        cout<<0;
    cout<<"\n";
  }

}

#include <bits/stdc++.h>
using namespace std;

#define LOCAL
#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int MAXN = 222;
int n;
string s;
int c[MAXN], marked[MAXN];

bool solve(int pos) {
	if(pos == -1)
		return true;
	if(marked[pos]) {
		for(int i = 0; i < pos; i++)
			if(marked[i] && s[i] > s[pos] && c[i] == c[pos])
				return false;
		return solve(pos - 1);
	}
	for(int chk : {0, 1}) {
		c[pos] = chk;
		bool ok = 1;
		vi v;
		for(int i = 0; i < pos; i++) {
			if(marked[i] && c[i] == chk && s[i] > s[pos])
				ok = 0;
			if(s[i] > s[pos]) {
				marked[i] = 1;
				v.pb(i);
				c[i] = 1 - chk;
			}
		}
		if(ok)
			if(solve(pos - 1))
				return true;
		for(int i : v) {
			c[i] ^= 1;
			marked[i] = 0;
		}
	}
	return false;
}

int32_t main() {
	cin >> n >> s;
	if(solve(n - 1)) {
		cout << "YES\n";
		for(int i = 0; i < n; i++)
			cout << c[i];
	}
	else
		cout << "NO";
	#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
}

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<string>
using namespace std;
#define ll long long
#define db double
#define endl "\n"
#define fo(a,b,c) for(int a = b;a <= c;a++)
#define mem(a,b) memset(a,b,sizeof a);
const int inf = 0x3f3f3f3f;
const int maxn = 2e3 + 10;
const int mod = 1e9 + 7;
int a[maxn];
int main(){
	char s[maxn];
	int n , ok = 1;
	cin >> n >> s;
	int cnt = -1;
	fo(i,1,n-1){
		if(s[i] < s[i-1]){
			a[i] = 1;
			if(cnt != -1 && s[cnt] > s[i]){
				ok = 0;
				break;
			}
			while(1){
				if(cnt == -1)cnt = 0;
				if(s[cnt] <= s[i] && cnt < i)cnt++;
				else{
					char b = s[i];
					for(int j = i;j > cnt;j--)s[j] = s[j-1];
					s[cnt] = b;
					break;
				}
			}
		}
	}
	if(ok == 1){
		cout << "YES\n" ;
		fo(i,0,n-1)cout << a[i];
		cout << endl;
	}
	else cout << "NO\n";
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<char, int> pr;
typedef pair<pair<int, int>, int> tup;

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}

inline void solve()
{
	int n;
	string s;
	cin >> n >> s;
	vector<pr> v(n);
	vector<int> c(n, -1);

	fore(i, 0, n)
	{
		v[i] = { s[i], i };
	}

	fore(i, 0, n)
	{
		char mn = 127;
		int ind = -1;
		fore(j, i, n)
		{
			if (mn > v[j].first)
			{
				mn = v[j].first;
				ind = j;
			}
		}

		if (c[v[ind].second] == -1)
		{
			c[v[ind].second] = 0;
			fore(j, i, ind)
			{
				if (c[v[j].second] == -1 || c[v[j].second] == 1)
					c[v[j].second] = 1;
				else
				{
					cout << "NO";
					return;
				}
			}
		}
		else
		{
			fore(j, i, ind)
			{
				if (c[v[j].second] == -1 || c[v[j].second] == !c[v[ind].second])
					c[v[j].second] = !c[v[ind].second];
				else
				{
					cout << "NO";
					return;
				}
			}
		}

		fr(j, ind + 1, i + 1)
		{
			swap(v[j],  v[j - 1]);
		}
	}

	cout << "YES\n";
	fore(i, 0, n)
		cout << c[i];
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 0,flag = 0;
    for(int i=n-1;i>0;i--){
        cnt = 0;
        //cout<<(int)(s[i])<<" ";
        for(int j=i-1;j>=0;j--){
            //cout<<(int)(s[j])<<" ";
            if( (int)(s[j]) > (int)(s[i]) ){
                cnt++;
                //int temp = 1+(int)(s[j]);
                for(int k=j-1;k>=0;k--){
                    if((int)s[k] > (int)(s[j])){
                        flag = 1;
                        break;
                    }
                }
                if(flag){
                    break;
                }
            }
        }
    }
    if(flag){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    int a[n] ;
    a[0] = 0;
    int lc = (int)s[0];
    int lt = 0;
    for(int i=1;i<n;i++){
        if( (int)s[i] < lc ){
            a[i] = 1 - lt;
        }
        else{
            a[i] = 0;
            lt = 0;
            lc = (int)s[i];
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i];
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int cnt[maxn];
int num[maxn];
int main()
{
    int n;
    cin>>n;
    string ss;
    cin>>ss;
    int flag=-INT_MAX;
    string ans=ss;
    sort(ans.begin(),ans.end());
   // cout<<ans<<endl;
    if(ss==ans){
        cout<<"YES"<<endl;
        for(int i=0;i<n;++i)
            cout<<0;
        cout<<endl;
    }else{
    memset(cnt,0,sizeof(cnt));
    //memset(num,0,sizeof(num));
    for(int i=0;i<ss.length();++i)
    {
      //  cout<<ss[i]-'a'<<endl;
       // cnt[ss[i]-'a']++;
        for(int j=ss[i]-'a'+1;j<=26;++j)
        {
          //  if(cnt[j]>=2)
          //  {
            //    flag=1;
          //  }
            cnt[ss[i]-'a']=max(cnt[ss[i]-'a'],cnt[j]+1);
        }
        num[i]=cnt[ss[i]-'a'];
        flag=max(flag,num[i]);
       // cout<<cnt[i]<<' '<<i<<endl;
    }
    if(flag>2)
        cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=0;i<ss.length();++i)
        {
            cout<<num[i]-1;
        }
        cout<<endl;
    }
    }
    return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

clock_t tp=clock();
#define fr(i,n) for(ll i=0;i<n;i++)
#define fa(i,n) for(auto i: n)
#define fx(i,n,j) for(ll i=n;i<j;i++)
#define frv(i,n,j) for(ll i=n;i>=j;i--)
#define mkp make_pair
#define PB push_back
#define PF push_front
#define PPB pop_back
#define PPF pop_front
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define time tp=clock()-tp;cerr<<"**** (Execution : "<<(double)(tp)/CLOCKS_PER_SEC<<"s) ****\n";
const long long mod = 1e9+7;
typedef long long int ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> SET;

ll power(ll a,ll b)          {ll ans=1;a=a; while(b>0){if(b&1)ans=(ans*a)  ;b>>=1;a=(a*a)  ;}return ans;}
ll power1(ll a,ll b,ll m=mod){ll ans=1;a%=m;while(b>0){if(b&1)ans=(ans*a)%m;b>>=1;a=(a*a)%m;}return ans;}
ll gcd(ll a,ll b)            {if (a==0) return b;   return gcd(b%a,a);}
ll ncr(ll n,ll r)            {if(n<r)return 0;ll p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;ll g=gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
ll lcm(ll a,ll b)            {return (a/gcd(a,b)*b);}
ll nCr(ll n,ll r)            {ll C[r+1]={1};fr(i,n+1)frv(j,min(i, r),1)C[j]=(C[j]+C[j-1])%mod;return C[r];}

bool compare_increasing(pair<ll,ll> l1,pair<ll,ll> l2){
    if(l1.F!=l2.F)  return (l1.F<l2.F);//greater< pair<int,int> >()
    else            return (l1.S<l2.S);
}

ll a[3505];

int main(){
    fast;
    //int tt; cin>>tt;  while(tt--)
    {
        ll n;
        string s;   cin >> n >> s;
        s='0'+s;
        ll a[n + 1] = {};

        for(char c = 'a'; c <= 'z'; c++)
        {
            ll i = 1, j = n+1;
            while(--j)    if(s[j] == c)    break;

            while(j){
                if(s[j] == c)                   i=a[j];
                else if(s[j]>c && a[j] == i)    a[j]=i+1;
                j--;
            }
        }
        ll x=*max_element(a+1,a+n+1);
        if(x>1) cout<<"NO";
        else{
            cout<<"YES\n";
            fr(i,n)    cout<<a[i+1];
        }
    }
    time;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,tot,ans[2333333],sum[2333333];
int main(){
    scanf("%d\n",&n);
    for(int i=1;i<=n;i++){
        char c=getchar();
        int maxx=0;
        for(int j=c-'a'+1;j<26;j++)maxx=max(maxx,sum[j]);
        ans[i]=maxx+1;
        sum[c-'a']=max(sum[c-'a'],maxx+1);
        tot=max(tot,maxx+1);
    }
    if(tot>2)puts("NO");
    else{puts("YES");for(int i=1;i<=n;i++)putchar(ans[i]+47);}
}

#include<bits/stdc++.h>
using namespace std;
#define si short int
#define ll long long
#define db double
#define ff first
#define s second

void solve(){
	int n;
	string s;
	cin >> n >> s;
	string res;
	char lst0 = 'a', lst1 = 'a';
	for (int i = 0; i < n; ++i) {
		if (s[i] >= lst0) {
			res += '0';
			lst0 = s[i];
		} else if (s[i] >= lst1) {
			res += '1';
			lst1 = s[i];
		} else {
			cout << "NO" << endl;
			return ;
		}
	}

	cout << "YES" << endl << res << endl;

}

int main(){
	solve();
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n;
int a[27];
int col[200005];
char x[200005];
int ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",x+1);
	for (int i=1;i<=n;i++)
	{
		int t=x[i]-'a',maxn=0;
		for (int j=t+1;j<=26;j++)
			maxn=max(maxn,a[j]);
		col[i]=maxn+1;
		ans=max(ans,col[i]);
		a[t]=max(a[t],maxn+1);
	}
	if (ans<=2)
	{
		printf("YES\n");
		for (int i=1;i<=n;i++)
			printf("%d",col[i]-1);
		printf("\n");
	}
	else
		printf("NO\n");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000;
int vis[maxn];
char s[maxn], t[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n >> s;
    for(int i = 0;i < n;i++) vis[i] = -1, t[i] = s[i];
    sort(t, t + n);
    for(int i = 0;i < n;i++)
    {
        if(vis[i] == -1){
            vis[i] = 0;
        }
        if(s[i] != t[i]){
            for(int j = i + 1;j < n;j++)
            {
                if(s[j] < s[i]) vis[j] = (vis[i] ^ 1);
            }
        }
    }
    bool flag = false;
    for(int i = 0;i < n;i++)
        for(int j = i + 1;j < n;j++){
         if(s[i] > s[j] && vis[i] == vis[j])  flag = true;
    }
    if(flag)  cout << "NO" << endl ;
	else
	{
		cout << "YES" << endl;
		for(int i = 0;i < n;i++) cout << vis[i];
		cout << endl;
	}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N=200005;
char a[N];
int f[N];
bool t[N];
vector <int> p;
int main (){
	int n,ans=1;scanf ("%d",&n);
	scanf ("%s",a+1);
	for (int i=1;i<=n;i++){
		f[i]=1;
		for (int j=1;j<i;j++)
			if (a[i]<a[j]) {
				f[i]=max(f[i],f[j]+1);
				if (f[i]==2) p.push_back(j);
			}
		ans=max(ans,f[i]);
	}
	if (ans>2) {puts("NO");return 0;}
	puts("YES");
	for (int i=0;i<p.size();i++) t[p[i]]=1;
	for (int i=1;i<=n;i++) printf ("%d",t[i]==1);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define  ll long long

/*
ll n , a , b , k , arr[200005] , ans;

bool bs(ll hp)
{
    ll l = 0 , h = 1e9 , mid  , idx=-1;
    while(l<=h)
    {
        mid = (l+h)/2;
        if (mid * a + mid * b < hp) {idx = max(idx , mid); l=mid+1;}
        else h=mid-1;
    }

    hp -= (a*idx + b*idx);
    ll tmp = hp/a + (hp%a != 0);

    if (k >= tmp/2)
    {
        k -= (tmp/2);
        cout << hp << " " << k << " how\n";
        return 1;
    }
    return 0;
}
*/

ll n;
string s;

vector<ll> adj[205] , v[28];
ll pos[205] , ans[205] , lev[2000];
bool vis[205][205] , visited[205] , inStack[205];

void dfs(int node , int par , int lvl)
{
    visited[node] = 1;
    lev[node] = lvl;
    inStack[node] = 1;
    ans[node] = lvl%2;

    for(int i=0; i<adj[node].size(); i++)
    {
        int ch = adj[node][i];
        if (ch == par) continue;
        if (!visited[ch]) dfs(ch , node , lvl+1);
        else
        {
            if (inStack[ch] && (lvl-lev[ch]+1)%2)
            {
                cout << "NO\n";
                exit(0);
            }
        }
    }

    inStack[node] = 0;
}

int main()
{
    cin >> n >> s;
    s = " "+s;

    for(int i=1; i<=n; i++)
    {
        v[s[i]-'a'].push_back(i);
    }

    for(int i=1; i<=n; i++)
    {
        int idx = s[i]-'a';
        for(int j=idx+1; j<26; j++)
        {
            for(int k=0; k<v[j].size(); k++)
            {
                int idx2 = v[j][k];
                if (idx2 < i && !vis[idx2][i] && !vis[i][idx2])
                {
                    vis[i][idx2]=1 , vis[idx2][i]=1;
                    adj[i].push_back(idx2) , adj[idx2].push_back(i);
                }
            }
        }
    }

    for(int i=1; i<=n; i++)
    {
        if (!visited[i]) dfs(i,i,1);
    }

    cout << "YES\n";
    for(int i=1; i<=n; i++)
        cout << ans[i];

    /*

    cin >> n >> a >> b >> k;
    for(int i=1; i<=n; i++)
    {
        cin >> arr[i];
    }
    sort(arr+1 , arr+n+1);

    for(int i=1; i<=n; i++)
    {
        cout << i << " aho\n";
        if (bs(arr[i])) ans++;
    }
     */

    /*
    ll t;
    cin >> t;
    while(t--)
    {
        ll n , l=-1 , r , x=0 , y=0 , tmp , tmpup , mn=1e9;
        string s;
        cin >> n >> s;
        s = " "+s;
        map<ll , stack<ll> > mp , mpup;
        ll pre[n+2]={} , preup[n+2]={};
        for(int i=1; i<=n; i++)
        {
            if (s[i] == 'L') pre[i]--;
            else if (s[i] == 'R') pre[i]++;
            else if (s[i] == 'U') preup[i]++;
            else if (s[i] == 'D') preup[i]--;
            pre[i] += pre[i-1];
            preup[i] += preup[i-1];
        }

        mp[0].push(0) , mpup[0].push(0);
        for(int i=1; i<=n; i++)
        {
            tmp = pre[i] , tmpup = preup[i];
         //   cout << pre[i] << " " << tmp << " " << preup[i] << " " << tmpup << " " << i << " leh\n";
            while(mp[tmp].size() && mpup[tmpup].size() && mp[tmp].top() != mpup[tmpup].top())
            {
                if (mp[tmp].top() > mpup[tmpup].top()) mp[tmp].pop();
                else mpup[tmpup].pop();
            }
            if (mp[tmp].size() && mpup[tmpup].size())
            {
                x = i - mp[tmp].top();
                if( x < mn)
                {
                    mn = x;
                    l = mp[tmp].top()+1 , r = i;
                }
            }

            mp[pre[i]].push(i) , mpup[preup[i]].push(i);
        }

        if (l == -1) cout << "-1\n";
        else
        cout << l << " " << r << "\n";
    }
*/

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
int main()
{
    fast();
    int n;
    string s,res;
    cin>>n>>s;
    char last0='a',last1='a';
    for(int i=0;i<n;i++)
    {
        if(s[i]>=last0)
        {
            res+='0';
            last0=s[i];
        }
        else if(s[i]>=last1)
        {
            last1=s[i];
            res+= '1';
        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<< "YES"<<endl<<res<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long int
int32_t main(){

//   int t;
//   cin>>t;
//  t=1;
//   while(t--){

      int n;
       cin>>n;

       string s;
       cin>>s;

       int dp[n+1];
       dp[0] = 0;
       int sp[n+1];
        // sp[0];

      for(int i =0 ; i <n;i++)
        {dp[i]=-1;
        sp[i]=-1;}

      string p = s;
      vector< pair< int,int> > v;

      for(int i = 0 ; i < n*n ; i ++ ){

          for(int j = 0 ; j < n-1; j ++){

              if(s[j] > s[j+1] )
              {

                  char tem  = s[j];
                  s[j] = s[j+1];
                  s[j+1] = tem;

                  v.pb(mp(j,j+1));
              }
          }

      }

    //   cout<<s<<endl;

    //   for(int i = 0; i <v.size() ; i++){
    //       cout<<v[i].fi<<" "<<v[i].se<<endl;
    //   }
    //   unordered_map<int,int>cn

    bool flag=true;

   for(int i  = 0;i < v.size() ; i ++){

       int ind1 = v[i].fi;
       int ind2 = v[i].se;

        if((dp[ind1] ==  dp[ind2]) && dp[ind1]!=-1)
            flag=false;

        if(dp[ind1]!=dp[ind2])
            {

                if(dp[ind1] == 0 || dp[ind1]==1)
                    dp[ind2] = 1-dp[ind1];
                else
                    dp[ind1] = 1-dp[ind2];

            }
        else if((dp[ind1] == dp[ind2]) && dp[ind1] ==-1)
            {
                dp[ind1] = 0;
                dp[ind2] = 1;
            }

        if(sp[ind1]==-1)
            sp[ind1]=dp[ind1];

        if(sp[ind2] == -1)
            sp[ind2]=dp[ind2];

        int temp = dp[ind2];
        dp[ind2] = dp[ind1];
        dp[ind1]  = temp;

   }

      if(flag==false)  cout<<"NO\n";
      else
      {
           cout<<"YES\n";

          for(int i = 0; i < n ; i++)
             {
                 if(sp[i] == -1)
                    cout<<0;
                  else
                    cout<<sp[i];

             }
      }

    //   for(int i = 0; i < n ; i++)
            //  cout<<dp[i];

//   }

}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	char num;
	vector<int>vec_int;
	vector<char>vec_char;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> num;
		vec_char.push_back(num);
	}
	for (int i = 0; i < n; i++)
	{
		bool key = true;
		for (int j = 0; j < i; j++)
		{
			if (vec_char[j] > vec_char[i])
			{
				for (int k = i; k < n; k++)
				{
					if (vec_char[i] > vec_char[k])
					{
						cout << "NO" << endl;
						return 0;
					}
				}
				key = false;
				vec_int.push_back(1);
				break;
			}
		}
		if (key)
		{
			vec_int.push_back(0);
		}
		if (i == n - 1)
			cout << "YES" << endl;
	}
	for (int i = 0; i < n; i++)
	{
		cout << vec_int[i];
	}
}

#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 50;
int n, ans[maxn], a[30];
string s;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0;i < n;i++)
    {
        int now = s[i] - 'a';
        ans[i] = a[now + 1] + 1;
        cnt = max(ans[i], cnt);
        a[now] = max(ans[i], a[now]);
        int mx = 0;
        for(int j = 26;j >= 0;j--){
            a[j] = max(mx, a[j]);
            mx = a[j];
        }
    }
    if(cnt > 2) cout << "NO" << endl;
    else {
        cout << "YES" << endl;
        for(int i = 0;i < n;i++) cout << ans[i] - 1;
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

vector<int>G[205];
int col[205];
int vis[205];
int n;
bool Cycle ;
string s;

void dfs(int u , int c)
{

    col[u] = c;
    vis[u] = 1;
    for(auto v : G[u])
    {
    	int newc = !c;

    	if(vis[v] == 0){
    		dfs(v , newc) ;
		}
		else if(col[u] == col[v])
		{
			Cycle = 1 ;
	    }

	}

}

int main()
{
	cin >> n;
	cin >> s;
	memset(vis , 0 ,sizeof vis) ;

	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < i ; j++)
		{
			if(s[j] > s[i])
			{
				G[i].push_back(j) ;
				G[j].push_back(i) ;
			}
		}
	}

	for(int i = 0 ; i < n ; i++)
	{
		if(Cycle) break;
		if(vis[i] == 0)
		dfs(i  , 0) ;
	}

	if(Cycle == 0)
	{
		cout <<"YES\n";
		for(int i = 0  ; i < n ; i++)
		cout << col[i];
	}
	else
	cout <<"NO\n";

	return 0;

}

#include <bits/stdc++.h>

#define int long long
#define pb push_back
#define F first
#define S second

using namespace std;

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector <int> v;
    int col[n];
    for(int i=n-1;i>=0;i--){
        auto it=lower_bound(v.begin(),v.end(),s[i]-'a');
        if(it==v.end()){
            v.pb(s[i]-'a');
            col[i]=v.size();
        }
        else{
            int ind=it-v.begin();
            col[i]=ind+1;
            v[ind]=s[i]-'a';
        }
    }
    if(v.size()>2){
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++) cout<<col[i]-1;
    return 0;
}

#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int n;
string s;
vi adj[200];
int col[200];

void dfs(int cur){
    for(int ch:adj[cur]){
        if(col[ch]==0){
            col[ch]=3-col[cur];
            dfs(ch);
        }else if(col[ch]==col[cur]){
            cout<<"NO";
            exit(0);
        }
    }
}

signed main(){
    FASTER;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]>s[j]){
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }

    for(int i=0;i<n;i++)if(!col[i]){
        col[i]=1;
        dfs(i);
    }
    cout<<"YES\n";
    for(int i=0;i<n;i++)cout<<col[i]-1;
}

#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int N = 330+100;

char s[N];

vector<int>p[N];
int color[N];

int main(){
    int n;
    cin>>n;
    scanf("%s",s);

    for(int i=0 ;i <n ;i ++){

        for(int  j =0 ; j <i ; j++){
            if(s[j] > s[i]){
                p[j].push_back(i);
            }
        }
    }
    int mx =0 ;
    for(int i= n-1 ; i>=0 ;i --){

        set<int>st;
        for(auto x : p[i]){
            st.insert(color[x]);
        }
        int nm = 1;
        while(st.count(nm))nm++;
        color[i] = nm;
        mx = max(mx,color[i]);
    }

    if(mx > 2){
        cout<<"NO\n";
        return 0;
    }
    cout<<"YES\n";

    for(int i=0; i <n ;i ++){
        printf("%d",color[i]-1);
    }

    return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }
  int random_modul() {

    uniform_int_distribution <int> u1(1e10, 1e11);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

    void solve () {

         /* --------- */
         int a; cin>>a;
    string s;
    cin>>s;
    int m[a];
    for (int i=0;i<a;i++) m[i]=s[i]-'a';
    int dp[a];
    int cur=0;
    vector<vector<int>> last(26);
    for (int i=0;i<a;i++) {
        int q=m[i]; int check=0;
        for (int j=q;j>=0;j--) if (last[j].size()!=0) {dp[i]=dp[last[j][last[j].size()-1]]; last[j].pop_back(); check=1; break; }
        if (check==0) {cur++; dp[i]=cur; }
        last[m[i]].push_back(i);
    }
   if (cur<=2) cout<<"YES\n"; else cout<<"NO";
   if (cur<=2) {
       for (int i=0;i<a;i++) cout<<dp[i]-1<<"";
   }
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);

       //  cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

    //  cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }

#include<bits/stdc++.h>
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << "\t" << x << endl
#else
#define debug(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
//inline ll Pow(ll a, ll n, ll MOD){ll t = 1;a %= MOD;while (n > 0){if (n & 1) t = t * a % MOD;a = a * a % MOD, n >>= 1;}return t % MOD;}
#define time cout << "运行时间为 ： " << setw(10) << (t2 - t1) / CLOCKS_PER_SEC << "秒" << endl
//double t1,t2;t1 = clock();t2 = clock();
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define lowbit(x) ((x) & -(x))
#define mem(a, b) memset(a, b, sizeof(a))
#define PI acos(-1)
#define endl '\n'
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define gcd(a,b) __gcd(a,b)
const int maxn = 2e5+100;
int ans[maxn];
int cnt[30],m[30];

signed main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin>>n;
    string s;
    cin>>s;
    int num = 1;
    cnt[1] = 1;
    m[1] = s[0]-'a';
    ans[0] = 1;
    for(int i = 1; i < n; i++)
    {
        int ok = 0;
        for(int j = 1; j<= num; j++)
        {
            if(s[i]-'a'>=m[j])
            {
                ok = 1;
                m[j] = s[i]-'a';
                cnt[j]++;
                ans[i] = j;
                break;
            }
        }
        if(!ok)
        {
            num++;
            m[num] = s[i]-'a';
            cnt[num]++;
            ans[i] = num;
        }
    }
    //cout<<num<<endl;
    if(num>2) cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i = 0; i < n; i++)
        {
            cout<<ans[i]-1;
        }
    }

}

#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
int n, c[200];
string s;
bool adj[200][200];

void dfs(int u, int cu)
{
    if (~c[u])
    {
        if (c[u] ^ cu)
        {
            cout << "NO";
            exit(0);
        }
        return;
    }
    c[u] = cu;
    for (int v = 0; v < n; ++v)
        if (adj[u][v])
            dfs(v, !cu);
}

int main()
{
    IOS;
    cin >> n >> s;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            if (s[i] > s[j])
            {
                adj[i][j] = adj[j][i] = 1;
            }
        }
    }
    memset(c, -1, 4 * n);
    for (int i = 0; i < n; ++i)
        if (c[i] < 0)
            dfs(i, 0);
    cout << "YES\n";
    for (int i = 0; i < n; ++i)
        cout << c[i];
}

//
//  main.cpp
//  gfdsd
//
//  Created by саша on 04.02.2020.
//  Copyright © 2020 саша. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
int main(int argc, const char * argv[]) {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> dp(n, -1), dp2(n, -1);
    dp[0] = 1;
    dp2[0] = 1;
    for (int i = 1; i < n; i++) {
        ll q, z = -1;
        q = s[i] - 'a';
        for (int j = i - 1; j >= 0; j--) {
            ll k;
            k = s[j] - 'a';
            if (k > q) {
                z = j;
            }
        }
        //cout <<z << endl;
        if (z == -1) {
            dp[i] = dp[i - 1];
            dp2[i] = dp[i];
        } else {
            ll kol;
            kol = dp[z];
            for (int j = z; j < i; j++) {
                if (kol != dp[j]) {
                    cout << "NO" << endl;
                    return 0;
                }
            }
            if (kol == 1) {
                dp[i] = 0;
                dp2[i] = 0;
            } else {
                dp[i] = 1;
                dp2[i] = 1;
            }
            swap(dp[z], dp[i]);
            string s1 = "";
            for (int j = 0; j < z; j++) {
                s1 += s[j];
            }
            s1 += s[i];
            for (int j = z; j < n; j++) {
                if (j != i) {
                    s1 += s[j];
                }
            }
            s = s1;
        }
    }
    cout << "YES" <<endl;
    for (int i = 0; i < n; i++) {
        cout << dp2[i];
    }
    //cout <<endl << s;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <map>
//#include <unordered_map>
#define mem( a ,x ) memset( a , x ,sizeof(a) )
#define rep( i ,x ,y ) for( int i = x ; i<=y ;i++ )
#define lson  l ,mid ,pos<<1
#define rson mid+1 ,r ,pos<<1|1
using namespace std;
typedef long long ll ;
typedef pair<int ,int> pii;
typedef pair<ll ,int> pli;
const int inf = 0x3f3f3f3f;
const ll mod=998244353;
const int N=1e5+50;
int T,n;
char s[2*N];
int f[2*N],bok[30];
int ans=0;
void solve(int n)
{
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
    {
        f[i]=1;
        for(int j=s[i]-'a'+1;j<26;j++)
            f[i]=max(f[i],bok[j]+1);
        bok[s[i]-'a']=f[i];
        ans=max(ans,f[i]);
    }
    if(ans<=2) {printf("YES\n");
    for(int i=1;i<=n;i++)
        printf("%d",f[i]-1);
    printf("\n");
    }
    else printf("NO\n");
}
int main()
{
    //scanf("%d",&T);
    T=1;
    while(T--)
    {
        scanf("%d",&n);
        solve(n);
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
int n, c[200];
string s;
bool adj[200][200];

void dfs(int u, int cu)
{
    if (~c[u])
    {
        if (c[u] ^ cu)
        {
            cout << "NO";
            exit(0);
        }
        return;
    }
    c[u] = cu;
    for (int v = 0; v < n; ++v)
        if (adj[u][v])
            dfs(v, cu ^ 1);
}

int main()
{
    IOS;
    cin >> n >> s;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            if (s[i] > s[j])
            {
                adj[i][j] = adj[j][i] = 1;
            }
        }
    }
    memset(c, -1, 4 * n);
    for (int i = 0; i < n; ++i)
        if (c[i] < 0)
            dfs(i, 0);
    cout << "YES\n";
    for (int i = 0; i < n; ++i)
        cout << c[i];
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

std::string s;
int f[210];
int n;
bool flag;

int main()
{
    read(n);
    std::cin >> s;
    f[0] = 1;
    for (int i = 1; i < n; ++i)
    {
        f[i] = 1;
        for (int j = 0; j < i; ++j)
            if (s[j] > s[i])
                f[i] = std::max(f[i], f[j] + 1);
        if (f[i] > 2)
        {
            flag = true;
            break;
        }
    }
    if (flag)
    {
        std::cout << "NO" << std::endl;
        return 0;
    }
    std::cout << "YES" << std::endl;
    for (int i = 0; i < n; ++i)
        std::cout << f[i] - 1;
    std::cout << std::endl;
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s;
string ans;

int pre=-1;
int n,i;
char maxc;
int main()
{
    cin>>n;
    cin.get();
    cin>>s;
    ans+="0";
    bool ok=1;
    maxc=s[0];
    for(i=1;i<n && ok;i++){
        if(maxc>s[i]){
            if(pre!=-1){
                if(s[pre]<=s[i])
                    ans+="1";
                else
                    ok=0;
            }
            else
                ans+="1";
            pre=i;
        }
        else
            ans+="0";
        maxc=max(maxc,s[i]);
    }
    if(ok)
        cout<<"YES\n"<<ans<<'\n';
    else
        cout<<"NO\n";
    return 0;
}

#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>
#include<unordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)
#define MOD2 (998244353)
#define pii pair<lli,lli>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define inf 1e10

using namespace std;
//using namespace __gnu_pbds;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0) {
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	string s; cin >> s; vector<pair<char, int>>arr0, arr1; arr0.push_back({ s[0],0 }); bool crap = false;
	for (int i = 1; i < n && !crap; i++) {
		if (s[i] >= arr0[arr0.size() - 1].first) {
			arr0.push_back({s[i],i});
		}
		else if (arr1.empty() || s[i] >= arr1[arr1.size() - 1].first) {
			arr1.push_back({ s[i],i });
		}
		else crap = true;
	}
	if (crap)cout << "NO";
	else {
		cout << "YES\n"; vector<int>ans;
		if (arr1.empty()) {
			for (int k = 0; k < n; k++)ans.push_back(0);
		}
		else {
			int ptr1 = 0, ptr2 = 0,n1=arr0.size(),n2=arr1.size();
			while (ptr1 < n1 && ptr2<n2) {
				if (arr0[ptr1].second < arr1[ptr2].second) {
					ptr1++; ans.push_back(0);
				}
				else {
					ptr2++; ans.push_back(1);
				}
			}
			while (ptr1 < n1) {
				ans.push_back(0); ptr1++;
			}
			while (ptr2 < n2) {
				ans.push_back(1); ptr2++;
			}
		}
		for (auto x : ans)cout << x;
	}
	//system("PAUSE");
}

#include <bits/stdc++.h>
#define ull unsigned long long
#define eps 5e-8
#define IT set<node>::iterator
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
/*
二分图
显然，对于每一对需要交换的字母对，这两个字母的颜色必定是不同的，我们可用在这两个字母之间连线表示不同
最后如果形成的图不是二分图，说明无法只用两种颜色染，输出NO，否则就把染的色输出
找需要交换的字母对(其实就是逆序对)，因为数据较小，可用通过冒泡排序找出来
*/
const int N=2e5+5;
int n,num[N],color[N];
char s[N];
vector<int>G[N];
bool dfs(int u,int c){
	color[u]=c;
	for(int i=0;i<G[u].size();i++){
		int j=G[u][i];
		if(!color[j]){
			if(!dfs(j,3-c))	return false;
		}
		else if(color[j]==c)	return false;
	}
	return true;
}
int main(){
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)	num[i]=i;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-1;j++){
			if(s[j]>s[j+1]){
				swap(s[j],s[j+1]);
				swap(num[j],num[j+1]);
				G[num[j]].push_back(num[j+1]);
				G[num[j+1]].push_back(num[j]);
			}
		}
	}
	bool flag=true;
	for(int i=1;i<=n;i++){
		if(!color[i]){
			if(!dfs(i,1)){
				flag=false;
				break;
			}
		}
	}
	if(flag){
		puts("YES");
		for(int i=1;i<=n;i++){
			if(color[i]==1)	printf("%d",0);
			else	printf("%d",1);
		}
	}
	else	puts("NO");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
string s,ans;

int main()
{
    int i,j,n,f;
    cin>>n>>s;
    char last1,last2;
    last1='a';last2='a';
    ans=""; f=0;
    for (i=0;i<n;i++)
      {
      	if (s[i]<last1&&s[i]<last2){
      		cout<<"NO"<<endl;f=1;
      		break;
		  }
		if (s[i]>=last1){
			ans+='0';
			last1=s[i];
		}
		else if (s[i]>=last2){
			ans+='1';
			last2=s[i];
		}
	  }
	if (f==0){
		cout<<"YES"<<endl;
	    cout<<ans<<endl;
	}
	return 0;
 }

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000;
int vis[maxn];
char s[maxn], t[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n >> s;
    for(int i = 0;i < n;i++) vis[i] = -1, t[i] = s[i];
    sort(t, t + n);
    for(int i = 0;i < n;i++)
    {
        if(vis[i] == -1){
            vis[i] = 0;
        }
        if(s[i] != t[i]){
            for(int j = i + 1;j < n;j++)
            {
                if(s[j] < s[i]) vis[j] = (vis[i] ^ 1);
            }
        }
    }
    bool flag = false;
    for(int i = 0;i < n;i++)
        for(int j = i + 1;j < n;j++){
         if(s[i] > s[j] && vis[i] == vis[j])  flag = true;
    }
    if(flag)  cout << "NO" << endl ;
	else
	{
		cout << "YES" << endl;
		for(int i = 0;i < n;i++) cout << vis[i];
		cout << endl;
	}
    return 0;
}

// BISMILLAHIR RAHMANIR RAHEEM
// ALLAH IS WATCHING ME
// ALLAH save us from COVID-19.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp> //order_of_key return number of elements less than x, find_by_order return index (pointer use kora lgbe)

using namespace std;
using namespace __gnu_pbds;

#define ull    unsigned long long
#define ll     long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses    "\n"
#define all(x) (x).begin(), (x).end()
//#define INF   ((int)2e18)
#define ii pair<ll, ll>

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

const int N=1e6+5;
const ll M=1e18;

typedef tree< ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

struct Edge
{
    int u, vv;
    bool operator<(Edge const& other)
    {
        return vv > other.vv;
    }
}; // eta joss jinis.krsukal er jnno and sort 1 out of 3 or more er jnno better

/////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////
//main function is here.........
int main()
{
    //ios
    ll len,mx;
    string s,ans,ss,ans1;
    cin>>len>>s;
    ss=s;
    for(ll i=0;i<len;i++){
        if(i==0){
                mx=s[i]-'a';
                ans+='0';
        }
        else{
                ll cur = s[i]-'a';
                if(cur<mx){
                                ans+='1';
                }
                else{
                     mx=max(cur,mx);
                     ans+='0';
                }
        }
    }
    ans1=ans;
    for(ll i=0;i<len-1;i++){
           if(ans[i]!=ans[i+1]){
                for(ll j=i+1;j>0;j--){
                       if(ss[j]<ss[j-1] && ans[j]!=ans[j-1]){swap(ss[j],ss[j-1]);swap(ans[j],ans[j-1]);}
                       else break;
                }
           }
    }
    sort(all(s));
    if(s==ss){
                cout<<"YES"<<ses<<ans1;
    }
    else {
                cout<<"NO";
    }
}

/*

*/

//Alhamdulillah

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

bool comp(pair<ll,ll> &a,pair<ll,ll> &b)
{
    return a.second < b.second;
}

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll n;
    cin >> n;
    vector<pair<char,ll>> s(n);
    vector<pair<ll,ll>> a(n);
    for(int i=0;i<n;i++)
    {
        char x;
        cin >> x;
        s[i] = {x,i};
        a[i] = {-1,i};
    }
    /*for(int i=0;i<n;i++)
       cout << s[i].first;
    cout << endl;*/
    ll f = 0;
    for(int i=0;i<26;i++)
    {
        char c = (i + 'a');
        ll sum = 0;
        //cout << c << endl;
        for(int i=0;i<n;i++)
        {
            if(s[i].first == c)
            {
                if(a[i].first == -1)
                    a[i].first = 1;
                for(int j=i-1;j>=0;j--)
                {
                    if(s[j].first > s[j+1].first)
                    {
                        if(a[j].first == -1)
                        {
                            a[j].first = 0;
                            swap(a[j],a[j+1]);
                            swap(s[j],s[j+1]);
                        }
                        else
                        {
                            if(a[j].first != a[j+1].first)
                            {
                                swap(a[j],a[j+1]);
                                swap(s[j],s[j+1]);
                            }
                            else
                                f = 1;
                        }
                    }
                    else
                        break;
                }
            }
        }
    }
    /*for(int i=0;i<n;i++)
       cout << s[i].first;
    cout << endl;*/
    if(f == 1)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
        sort(a.begin(),a.end(),comp);
        for(int i=0;i<n;i++)
            cout << a[i].first;
    }
}

#include <bits/stdc++.h>

#define mod 998244353
#define  ll long long
using namespace std;
int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    string ans;
    vector<char> vec;
    ans.resize(n,'0');

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<i;j++)
        {
            if(s[j]>s[i])
            {
                ans[i]='1';
                vec.push_back(s[i]);

            }

        }
    }
    for(int i=1;i<vec.size();i++)
    {
        if(vec[i]<vec[i-1])
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    cout<<ans;

}

#include<bits/stdc++.h>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
#define PI 3.1415926536
#define rep(i,j,n) for(int i = j; i < n; i++)
#define ll long long
#define vi vector<int>
#define pb push_back
#define F first
#define S second

const double err = 1e-12;
const int N = 2e5 + 5;

void solve(){
   int n; cin >> n;
   string s; cin >> s;
   string res = "0"; bool f = true; char mx = s[0], bmx = '\0';
   rep(i,1,s.length())
   {
      if(s[i] >= mx) {mx = s[i]; res += '0';}
      else
      {
         if(bmx && bmx > s[i]) {f = false; break;}
         else {if(!bmx) bmx = s[i]; else bmx = max(bmx, s[i]);}

         if(res[i-1] == '0' ) {res += '1';}
         else
         {
            if(s[i-1] <= s[i]) {res += '1';}
            else
            {
               f = false; break;
            }
         }
      }
   }
   if(!f) cout<<"NO\n";
   else {
      cout<<"YES\n"<<res<<endl;
   }
}

int main(){
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
	FASTER;
   int t = 1;
   // cin >> t;
   while(t--) solve();
   return 0;
}

//

#include<string>
#include <iostream>
#include<set>
#include <algorithm>
#include<vector>
#include<map>
#include<cmath>
typedef long long ll;
const int nmax = 30000;

using namespace std;

#define x1 first
#define y1 second
#define MP make_pair
#define PB push_back
#define all(a) (a).begin(), (a).end()
long long max(long long a, long long b) {
	if (a > b) {
		return a;
	}
	else {
		return b;
	}
}
pair < ll, ll > max(pair < ll, ll >a, pair < ll, ll >b) {
	if (a > b) {
		return a;
	}
	else {
		return b;
	}
}
int ex_c(int a, int b) {
	if (a == 0 && b == 1) {
		return 2;
	}
	if (a == 1 && b == 2) {
		return 0;
	}
	if (a == 0 && b == 2) {
		return 1;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main()
{
	int  n;
	cin >> n;
	string s;
	cin >> s;
	vector<int>col(n,-1);
	for (int i = 0;i < n;i++) {
		if (col[i] == -1) {
			col[i] = 0;
			for (int j = i+1;j < n;j++) {

				if (s[i] > s[j] && col[j] == -1) {
					col[i] = 0;
					col[j] = 1;
				}
				if (s[i] > s[j] && col[j] == 1) {
					col[i] = 0;
				}
				if (s[i] > s[j] && col[j] == 0) {
					col[i] = 1;
				}

			}
		}

	}
	int k = 0;
	int anns = 0;
	for (int i = 0;i < n;i++) {
		int co;
		for (int j = i + 1;j < n;j++) {
			if (s[i] > s[j] && k == 0) {

				co = col[i];
				if (co == col[j]) {
					anns++;
					break;
				}
				k++;
			}
			else if (s[i] > s[j] && k != 0 && col[i]==col[j]) {
				anns++;
				break;
			}
		}
		if (anns > 0) {
			break;
		}
	}

	if (anns > 0) {
		cout << "NO";
	}
	else {
		cout << "YES"<<endl;
		for (int i = 0;i < n;i++) {
			cout << col[i];
		}
	}

}

#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;

    int n ; string s ;
    cin >> n >> s ;
    char last0 = 'a' , last1 = 'a' ;
    string res = "" ;
    for(int i = 0 ; i < n ; i++){
        if(s[i] >= last0){
            last0 = s[i] ;
            res += '0' ;
        }
        else if(s[i] >= last1){
            last1 = s[i] ;
            res += '1' ;
        }
        else{
            cout << "NO" << endl ; return 0 ;
        }
    }
    cout << "YES" << endl << res << endl ;
    return 0  ;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define MOD 1000000007LL
#define INF 100000000

ll exp(ll a, ll n){
    if (n==0)return 1;
    ll residue = 1, result = a;
    while(n>1LL){
        if (n%2LL==1LL) residue = residue * residue % MOD;
        result = result * result % MOD;
        n = n>>1;
    }

    return residue * result % MOD;

}

void sieve(ll n, vector<bool> &isPrime){
    for (int i=0;i<=n;i++) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for (ll i=2;i*i<=n;i++){
        if (!isPrime[i]) continue;
        for (ll j=i*i;j<=n;j+=i){
            isPrime[j] = false;
        }
    }
}

int main() {
   // freopen("input.txt", "r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    string s;
    cin>>n>>s;
    vector<int> lastPos(26, -1), firstPos(26, INF);

    for (int i=0;i<n;i++) lastPos[s[i] - 'a'] = max(lastPos[s[i] - 'a' ], i), firstPos[s[i]-'a'] =  min(firstPos[s[i]-'a'], i);
    vector<int> color(26, -1);
    int m = 1<<26;
    bool ans = true;
    queue<int> q;
    int top;
    vector<bool> visited(26, false);
    for (int i=0;i<26;i++){
        if (!visited[i]){
            q.push(i);
            color[i] = 1;
            while(!q.empty()){
                top = q.front();
                q.pop();
                for (int j=lastPos[top];j>=0;j--){
                    if (s[j]-'a'>top){
                        if (color[s[j]-'a']!=-1 && color[s[j]-'a']==color[top])ans =false;
                        else {
                                color[s[j]-'a'] = !color[top];
                                if (!visited[s[j]-'a']){
                                        visited[s[j]-'a']=true;
                                        q.push(s[j]-'a');
                                }
                        }
                    }
                }
            }
        }
    }
    if (ans){
        cout<<"YES"<<endl;
        for (int i=0;i<n;i++){
           cout<<color[s[i]-'a'];

        }
    } else cout<<"NO"<<endl;

    return 0;
}

#include<stdio.h>
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 200;

void modificar_variables(char* a, bool* coloring, int len, bool* out_bool) {
  if (len <= 2) {
    *out_bool = true;
    coloring[0] = false;
    if (len == 2) {
      coloring[1] = true;
    }
  }
  // 3LDS
  int LDS[MAX_SIZE];
  LDS[0] = 1;
  int max_total = 0;
  for (int i = 1; i < len; i++ ) {
    int max_iter = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (a[j] > a[i]) {
        max_iter = max(max_iter, LDS[j] + 1);
      }
    }
    LDS[i] = max_iter;
    max_total = max(max_total, LDS[i]);
    if (max_total >= 3) {
      break;
    }
  }

  if (max_total > 2) {
    *out_bool = false;
  }
  else {
    *out_bool = true;
    coloring[0] = false;
    for (int i = 1; i < len; i++) {
      if (int(a[i - 1]) > int(a[i])) {
        coloring[i] = true;
      }
      else {
        coloring[i] = coloring[i - 1];
      }
    }
  }
}

int main(){

  int len;
  char string_input[MAX_SIZE];
  bool out_bool;
  bool coloring[MAX_SIZE];
  scanf("%d", &len);
  scanf("%s", string_input);
  modificar_variables(string_input, coloring, len, &out_bool);
  if (out_bool) {
    printf("YES\n");
    for (int i = 0; i < len; i++) {
      printf("%d ", coloring[i]);
    }
    printf("\n");
  }
  else {
    printf("NO\n");
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
char str[210],ch1,ch2,ans[210];
int main()
{
	int n;
	cin>>n>>str;
	for(int i=0;i<n;i++)
	{
		if(str[i]>=ch1)
		{
			ch1=str[i];
			ans[i]='0';
		}
		else if(str[i]>=ch2)
		{
			ch2=str[i];
			ans[i]='1';
		}
		else
			puts("-1");
	}
	puts("YES");
	puts(ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
struct node{
    char c;
    int id;
};
vector<node>ve;
vector<node>v;
int ans[210];
bool cmp1(node x,node y)
{
    return x.c<y.c;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        char te;
        cin>>te;
        ve.push_back({te,i});
        v.push_back({te,i});
    }
    sort(ve.begin(),ve.end(),cmp1);
//    for(int i=0;i<n;i++)cout<<ve[i].c;
//    cout<<endl;
    for(int i=0;i<n;i++){
        if(v[i].c!=ve[i].c){
                int flag=0;
//                cout<<ve[i].c<<"$"<<endl;
//                for(int i=0;i<n;i++)cout<<v[i].c;
//                cout<<endl;
            for(int j=i+1;j<n;j++){
                if(ans[v[j].id]>=1){
                        //cout<<v[j].c<<endl;
                    cout<<"NO"<<endl;
                    return 0;
                }
                if(v[j].c==ve[i].c&&ans[v[j].id]==0){
                    //cout<<v[j].c<<endl;
                    ans[v[j].id]=1;
                    flag=j;break;

                }else{
                    ans[v[j].id]=2;
                }
            }
            //cout<<flag<<endl;
            for(int j=flag;j>i;j--){
                char tempc;int tempid;
                tempc=v[j].c;
                tempid=j;
                v[j].c=v[j-1].c;
                v[j].id=v[j-1].id;
                v[j-1].c=tempc;
                v[j-1].id=tempid;
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++){if(ans[i]==2)cout<<0;else cout<<ans[i];}
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<char, int> pr;
typedef pair<pair<int, int>, int> tup;

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}

inline void solve()
{
	int n;
	string s;
	cin >> n >> s;
	vector<pr> v(n);
	vector<int> c(n, -1);

	fore(i, 0, n)
	{
		v[i] = { s[i], i };
	}

	fore(i, 0, n)
	{
		char mn = 122;
		int ind = -1;
		fore(j, i, n)
		{
			if (mn > v[j].first)
			{
				mn = v[j].first;
				ind = j;
			}
		}

		if (c[ind] == -1)
		{
			c[ind] = 0;
			fore(j, i, ind)
			{
				if (c[v[j].second] == -1 || c[v[j].second] == 1)
					c[v[j].second] = 1;
				else
				{
					cout << "NO";
					return;
				}
			}
		}
		else
		{
			fore(j, i, ind)
			{
				if (c[v[j].second] == -1 || c[v[j].second] == !c[v[ind].second])
					c[v[j].second] = !c[v[ind].second];
				else
				{
					cout << "NO";
					return;
				}
			}
		}

		fr(j, ind + 1, i + 1)
		{
			swap(v[j], v[j - 1]);
		}
	}

	cout << "YES\n";
	fore(i, 0, n)
		cout << c[i];
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

#include <bits/stdc++.h>
using namespace std;
int n,l,r,gap;
char s[205],t[205];
int m[205],ans[205],vis[205];
int main()
{
    scanf("%d",&n);
    scanf("%s",s);
    for(int i = 0;i < n;i++)
        t[i] = s[i];

    sort(t,t+n);
    for(int i = n-1;i >= 0;i--)
    {
        l = r = i;
        while(1)
        {
//            printf("l[%d]:%c r[%d]:%c s[%d]:%c\n",l,t[l],r,t[r],i,s[i]);
            if (l >= 0&&t[l] == s[i]&&!vis[l])
            {
                m[i] = i-l;
                vis[l] = 1;
                break;
            }
            else if (r < n&&t[r] == s[i]&&!vis[r])
            {
                m[i] = r-i;
                ans[i] = 1;
                vis[r] = 1;
                break;
            }
            l -= 1;
            r += 1;
        }
    }
    int turn = 0;
//    cout << "m" << endl;
//    for(int i = 0;i < n;i++) printf("%d ",m[i]);
//    cout << "\nans" << endl;
//    for(int i = 0;i < n;i++) printf("%d",ans[i]);cout<<endl;
    for(int i = 0;i < n;i++)
    {
        if (m[i])
        {
            if (m[i]&1)
            {
                printf("NO");
                return 0;
            }
            if (ans[i]) turn += m[i];
            else turn -= m[i];
        }
        else if (turn)
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES\n");
    for(int i = 0;i < n;i++) printf("%d",ans[i]);

    return 0;
}

/** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string a;
    cin >> N >> a;
    ll dp[210] = {}, idx[210];
    fill(dp, dp+N, INF);
    ll nxt[210] = {};
    fill(nxt, nxt+N, -1);
    rep(i,0,N){
        ll pos = lower_bound(dp, dp+N, a[i]) - dp;
        dp[pos] = a[i];
        idx[pos] = i;
        if(pos != 0) nxt[i] = idx[pos-1];
    }

    ll len = 0;
    rrep(i,N-1,0){
        if(dp[i] != INF){
            len = i+1;
            break;
        }
    }
    vector<ll> res;
    ll p = idx[len-1];
    while(p >= 0){
        res.push_back(p);
        p = nxt[p];
    }
    reverse(res.begin(), res.end());
    map<ll,ll> mp;
    for(auto &e: res) mp[e]++;
    vector<ll> v2;
    rep(i,0,N){
        if(mp[i] == 0) v2.push_back(i);
    }

    // reverse(v.begin(), v.end());
    // reverse(v2.begin(), v2.end());
    ll sz = v2.size();
    rep(i,0,sz-1){
        if(a[v2[i]] > a[v2[i+1]]){
            print("NO");
            return 0;
        }
    }
    ll ans[210] = {};
    for(auto &e: res) ans[e] = 1;
    print("YES");
    rep(i,0,N) cout << ans[i];
    cout << endl;

}

#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;

    int n ;  string s ;
    cin >> n >> s ;
    vector <int> v(n + 1 , -1) ;
    string q ;
    q = s ;
    while(true){
        //cout << s << endl ;
        int f = 0 ;
        for(int i = 1 ; i < n ; i++){
            if(s[i] < s[i - 1] and v[i] == v[i -1] and v[i] != -1){
                cout << "NO" << endl ;
                return 0 ;
            }
            else{
                if(s[i] < s[i - 1] and v[i] == -1 and v[i - 1] != -1){
                    swap(s[i] , s[i - 1]) ;
                    swap(v[i] , v[i - 1]) ;
                    v[i - 1] = 1 - v[i] ;
                    f = 1 ;
                }
                else if(s[i] < s[i - 1] and v[i] != -1 and v[i - 1] == -1){
                    swap(s[i] , s[i - 1]) ;
                    swap(v[i] , v[i - 1]) ;
                    v[i] = 1 - v[i - 1] ;
                    f = 1 ;
                }
                else if(s[i] < s[i -1] and v[i] == -1 and v[i - 1] == -1){
                    swap(s[i] , s[i - 1]) ;
                    v[i] = 1 ;
                    v[i - 1] = 0 ;
                    f = 1 ;
                }
                else if(s[i] < s[i - 1] and v[i] != v[i - 1]){
                    swap(s[i] , s[i - 1]) ;
                    swap(v[i] , v[i - 1]) ;
                    f = 1;
                }
            }
        }
        if(!f){
            break ;
        }
    }
    cout << "YES" << endl ;
    // for(auto i : v){
    //     cout << i << " " ;
    // }
    // return 0  ;
    vector < int > res ;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ;j < n ; j++){
            if(q[i] == s[j]){
                cout << (v[j] != -1 ? v[j] : 0) << " " ;
                s[j] = 'x' ;
                break ;
            }
        }
    }
    return 0  ;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
int main()
{
    fast();
    int n, last0,last1;
    string s,res;
    cin>>n>>s;
    last0=last1='a';
    for(int i=0;i<n;i++)
    {
        if(s[i]>=last0)
        {
            res+="0";
            last0=s[i];
        }
        else if(s[i]>=last1)
        {
            last1=s[i];
            res+="1";
        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    printf("YES\n");
    cout<<res<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int>> a;
    a.resize(n + 1);
    int b[n + 1];
    scanf("\n");
    for (int i = 1; i <= n; i++) {
        char ch;
        scanf("%c", &ch);
        a[i] = {{ch, -1}, i};
        b[i] = ch;
    }
    sort(b + 1, b + n + 1);
    int ind = 1;
    int ch = 1;
    while (1) {
        int i;
        for (i = ind; i <= n; i++) {
            if (a[i].first.first == b[ind]) {
                break;
            }
        }
        int clr1 = 0;
        int clr0 = 0;
        for (int j = ind; j < i; j++) {
            if (a[j].first.second == 1) {
                clr1++;
            }
            else if (a[j].first.second == 0) {
                clr0++;
            }
        }
        if (clr0 > 0 && clr1 > 0) {
            ch = 0;
            break;
        }
        else if (clr0 > 0 && a[i].first.second == 0) {
            ch = 0;
            break;
        }
        else if (clr1 > 0 && a[i].first.second == 1) {
            ch = 0;
            break;
        }
        else {
            if (clr0 > 0) {
                for (int j = ind; j < i; j++) {
                    a[j].first.second = 0;
                }
                a[i].first.second = 1;
            }
            else if (clr1 > 0) {
                for (int j = ind; j < i; j++) {
                    a[j].first.second = 1;
                }
                a[i].first.second = 0;
            }
            else {
                if (a[i].first.second == -1) {
                    for (int j = ind; j < i; j++) {
                        a[j].first.second = 1;
                    }
                    a[i].first.second = 0;
                }
                else {
                    for (int j = ind; j < i; j++) {
                        a[j].first.second = 1 - a[i].first.first;
                    }
                }
            }
            pair<pair<int, int>, int> temp = a[i];
            a.erase(a.begin() + i);
            a.insert(a.begin() + ind, temp);
        }
        ind++;
        if (ind == n + 1) {
            break;
        }
    }
    if (ch == 0) {
        cout << "NO";
    }
    else {
        cout << "YES" << endl;
    }
    int c[n + 1];
    for (int i = 1; i <= n; i++) {
        c[a[i].second] = a[i].first.second;
    }
    for (int i = 1; i <= n; i++) {
        cout << c[i];
    }

}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define it register int
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
const int maxn=2e5+10;
int n,a[500],b[500]={0};
char s[500];
int main(){
          mem(a,-1);
          scanf("%d",&n);
          scanf("%s",s);
          a[0]=0;
          int ff=1;
          for(it i=1;i<n;i++){
                    int f=1;
                    for(it j=i-1;j>=0;j--){
                                        //cout<<s[i]<<s[j]<<endl;
                              if(s[i]<s[j]){
                                        if(a[i]==-1){
                                                  a[i]=1-a[j];f=0;
                                        }
                                        else{
                                                  if(a[i]==a[j] && b[j]==0){
                                                            ff=0;break;
                                                  }
                                                  else if(a[i]==a[j] && b[j]==1){
                                                            b[j]=0;a[j]=1-a[i];
                                                  }
                                        }
                              }
                    }
                    if(!ff){break;}
                    if(f){a[i]=a[i-1];b[i]=1;}
          }
          if(ff){
                    printf("YES\n");
                    for(it i=0;i<n;i++){
                              printf(i==n-1?"%d\n":"%d",a[i]);
                    }
          }
          else{
                    printf("No\n");
          }
          return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fp(i,a,b) for(register int i=a;i<=b;i++)
#define fb(i,a,b) for(register int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define scf(a,b) scanf("%d%d",&a,&b)
int n,maxx,dp[300],co[300];char s[300];
int main(){
	sc(n);cin>>(s+1);
	fp(i,1,n){
		dp[i]=1;
		fp(j,1,i-1)
		if(s[j]>s[i]){
			dp[i]=max(dp[i],dp[j]+1);
			maxx=max(maxx,dp[i]);
		}
	}
	if(maxx>2) puts("NO");
    else{
    	fp(i,1,n-1){
    		fp(j,i+1,n){
    			if(s[j]<s[i]) co[j]=abs(1-co[i]);
			}
		}
		fp(i,1,n) printf("%d",co[i]);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
#define inf ll(1e17)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
#define N 1000001
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
int32_t main()
{  ll i,n,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
   ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   cin>>n ;
   string s ;
   cin>>s ;
   auto s1=s ;
   sort(s1.begin(),s1.end()) ;
   ll arr[n] ;
   for(i=0;i<n;i++)
   {
       arr[i]=-1 ;
   }
   x=0 ;
   bool flag=true ;
   for(i=0;i<n;i++)
   {
       if(s[i]==s1[i])
        {
            if(arr[i]==-1)
                arr[i]=x  ;
            continue ;
        }
        for(j=i+1;j<n;j++)
        {
            if(s[j]==s1[i])
                break ;
        }
        while(j>i)
        {  swap(s[j],s[j-1]) ;
            if(arr[j]==-1)
                arr[j]=x ;
            else if(arr[j]!=x)
            {
                flag=false ;
                break ;
            }
            j-- ;
        }
        if(!flag)
            break ;
        x=x^1 ;
        arr[i]=x ;

   }
   if(!flag)
   {
       cout<<"NO\n" ;
       return 0 ;
   }
   cout<<"YES\n" ;
   for(i=0;i<n;i++)
    cout<<arr[i] ;
   return 0; }

#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> v;
    for(int	i = 0; i < n; ++i){
		int m = 0;
		for(int j = 0; j<i; ++j){
			if(s[j]>s[i]){
				m++;
			}
		}
		if(m > 2){
		 //cout << i <<endl;
		   puts("NO");
		   return 0;
		}
		v.push_back((m)?1:0);
	}
	cout << "YES" <<endl;
	for(int i = 0; i <(int)v.size(); ++i){
		cout << v[i];
	}
	cout << "\n";
}

#pragma region
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz size()
#define mem(a,b) memset(a,b,sizeof(a))
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pw(x) (1LL<<(x))
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
#define debug(x)   {cerr <<#x<<" = " <<x<<"\n"; }
#define debuga(a, n) {cerr << #a << " = "; forn(i,n) cerr<<a[i]<<' '; cerr<<endl;}
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define mmax(a,b) a = (a) > (b) ? (a) : (b)
#define mmin(a,b) a = (a) < (b) ? (a) : (b)
#define has(c,x) (c.find(x)!=c.end())

#define rep(i,k,n) for(int (i) = int(k); i < int(n); ++i)
#define IOS ios_base::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<ll, vector<int> > plv;
#define F first
#define S second
#pragma endregion

#define GOOGLE 0

template <typename T> void readv(vector<T> &v, int x) {
	v = vector<T>(x);
	rep(i, 0, x) cin >> (v[i]);
}

/* DATA STRUCTURES */
int n;
string s;
/* ********************** */

/* INPUT */
void _input() {
	cin >> n >> s;
}
/*********************** */

/* SOLVE */
int rand(int a, int b) {
	return a + rand() % (b - a + 1);
}

bool solve() {
	return false;
}

void dfs(int u, vector<vector<int>>& g, vector<int>& sol, vector<bool> &vis){
	if(vis[u]) return;
	vis[u] = true;
	for(int x: g[u]){
		sol[x] = 1 - sol[u];
		dfs(x, g, sol, vis);
	}
}

void _solve() {
	vector<int> sol(n, -1);
	rep(i, 0, n) {
		char c = s[i];
		bool l = false, r = false;
		rep(j, 0, i) {
			if (s[j] > c) {
				l = true;
				break;
			}
		}
		rep(j, i + 1, n) {
			if (s[j] < c) {
				r = true;
				break;
			}
		}
		if (l and r) {
			cout << -1 << endl;
			return;
		}
	}
	vector<vector<int>> g(n);

	rep(i, 0, n) {
		char c = s[i];
		int z = 0, o = 0;
		rep(j, 0, i) {
			if (s[j] > c) {
				g[i].push_back(j);
			}
		}
		rep(j, i + 1, n) {
			if (s[j] < c) {
				g[i].push_back(j);
			}
		}
	}
	vector<bool> vis(n, false);
	rep(i,0,n){
		if(!vis[i]){
			sol[i] = 0;
			dfs(i, g, sol, vis);
		}
	}
	cout << "YES" << endl;
	for (auto e : sol) cout << e;
	cout << endl;
}
/* ********************** */

int main()
{
	srand(time((unsigned int)NULL));
	double st = clock();
	//cout.setf( ios_base::unitbuf);
	IOS
	int qq = 1;
	if (GOOGLE) cin >> qq;
	int cc = 0;
	while (cc++ < qq) {
		_input();
		//cout << "Case #" << cc++ << ": ";
		_solve();
	}

	cerr << 1000.0 * (1.0 * clock() - st) / (1.0 * CLOCKS_PER_SEC) << " ms ellapsed\n";
}

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
#define trace(x)  cerr << #x << ": " << x << endl;
int main()
{
	fast;
	ll n;cin>>n;string s;cin>>s;vector<ll> ans(n);ans[n-1]=0;ll cur=0;char mini=s[n-1];ll minidx=n-1;
	for(ll i=1;i<n;i++)
	{
		if(s[i]<s[i-1])
		{
			cur++;if(cur>1){cout<<"NO";return 0;}
		}
		else cur=0;
	}
	for(ll i=n-2;i>=0;i--)
	{
		if(s[i]>mini)
		{
			ans[i]=(ans[minidx]+1)%2;
		}
		else
		{
			ans[i]=ans[minidx];mini=s[i];minidx=i;cur=0;
		}
	}
	cout<<"YES\n";for(auto u:ans)cout<<u;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 2e2+20;
ll mod=1e9 + 7;
bool mark[maxn], c[maxn][maxn], a[maxn][2];
double dp[maxn][maxn][maxn];
const int inf=1e9;

int main()
{
	int n;
	cin >> n;

	string s,x;
	cin >> s;

	x=s;
	sort(x.begin(),x.end());

	for(int i=n-1;i>=0;i--)
		for(int j=0;j<n;j++)
			if(s[j] == x[i] && !mark[j])
			{
				mark[j]=1;
				for(int k=j+1;k<n;k++)
					if(!mark[k] && s[j]!=s[k])
						c[j][k]=1;
			}

	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(c[i][j]==1)
				for(int k=j+1;k<n;k++)
					if(c[i][k]==1 && c[j][k]==1)
						return cout << "NO", 0;

	cout << "YES" << endl;

	for(int i=n-1;i>=0;i--)
		for(int j=0;j<n;j++)
			if(s[j] == x[i] && !a[j][1])
				if(i == n-1)
					for(int k=j+1;k<n;k++)
					{
							a[j][1]=1;
							a[j][0]=1;
							a[k][1]=1;
							a[k][0]=0;
					}
				else
					for(int k=j+1;k<n;k++)
					{
						a[j][1]=1;
						a[j][0]=1;
						if(!a[k][1])
						{
							a[k][1]=1;
							a[k][0]=abs(a[j][0]-c[j][k]);
						}
					}

	for(int i=0;i<n;i++)
		cout << a[i][0];
}

#include<bits/stdc++.h>
					using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
	using namespace std;
                    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
                    #define pb push_back
                    #define ff first
                    #define ss second
                    #define sz size()
                    #define mp make_pair
                    #define int long long int
                    #define double long double
                    #define bp __builtin_popcountll
                    #define FOR(i,a,b) for(int i=a;i<b;i++)
                    #define ROR(i,a,b) for(int i=a;i>=b;i--)

                    const int MAXN=1e7+7;
                    const int MA=5e3+5;

                               int gcd(int a, int b)
            {
                if (b == 0)
                    return a;
                return gcd(b, a % b);

            }

            int chk(char a)
            {
              if(a=='L')
              return 10;
              if(a=='R')
              return -10;
              if(a=='U')
              return 1;

              return -1;
            }

int32_t main()
{
  FAST
  int t;
  cin>>t;
  char arr[t+10];
  int arr2[t]={0},arr3[t]={0};
  cin>>arr;
  int k=1;
  arr2[0]=arr3[0]=-1;
  for(int i=1;i<t&&k==1;i++)
  {
   for(int j=i;j>0&&k==1;j--)
   {
     if(arr[j]>=arr[j-1])
     {
     if(arr2[j]==0)
     {
        if(arr[j]==arr[j-1])
      arr2[j]=arr3[j]=arr2[j-1];
         else
         {
             if(arr2[j-1]==-1)
                 arr2[j]=arr3[j]=1;
             else
                 arr2[j]=arr2[j]=-1;
         }
     }
     break;
     }
     if(arr[j-1]>arr[j])
     {

      if(arr2[j-1]==-1&&arr2[j]==0)
      {

      arr2[j]=1;
      arr3[j]=1;
      swap(arr2[j],arr2[j-1]);
      swap(arr[j-1],arr[j]);
      }
      else if(arr2[j]==0)
      {
        arr2[j]=-1;
        arr3[j]=-1;
        swap(arr2[j],arr2[j-1]);
        swap(arr[j-1],arr[j]);
      }
      else
      {
        if(arr2[j-1]==arr2[j])
        {
          k=0;
          break;
        }
        else
        {
          swap(arr2[j],arr2[j-1]);
          swap(arr[j-1],arr[j]);
        }

      }

     }

   }
  }
  if(k==0)
  {
    cout<<"N0\n";
  }
  else
  {
    cout<<"YES\n";
    for(int i=0;i<t;i++)
     if(arr3[i]==1)
    cout<<arr3[i]<<" ";
        else
        cout<<0<<" ";
    cout<<"\n";
  }

}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define MOD 1000000007LL
#define INF 100000000

ll exp(ll a, ll n){
    if (n==0)return 1;
    ll residue = 1, result = a;
    while(n>1LL){
        if (n%2LL==1LL) residue = residue * residue % MOD;
        result = result * result % MOD;
        n = n>>1;
    }

    return residue * result % MOD;

}

void sieve(ll n, vector<bool> &isPrime){
    for (int i=0;i<=n;i++) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for (ll i=2;i*i<=n;i++){
        if (!isPrime[i]) continue;
        for (ll j=i*i;j<=n;j+=i){
            isPrime[j] = false;
        }
    }
}

int main() {
    //freopen("input.txt", "r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    string s;
    cin>>n>>s;
    vector<int> lastPos(26, -1), firstPos(26, INF);

    for (int i=0;i<n;i++) lastPos[s[i] - 'a'] = max(lastPos[s[i] - 'a' ], i), firstPos[s[i]-'a'] =  min(firstPos[s[i]-'a'], i);
    vector<int> color(26, -1);
    int m = 1<<26;
    bool ans = true;
    queue<int> q;
    int top;
    vector<bool> visited(26, false);
    for (int i=0;i<26;i++){
        if (!visited[i]){
            q.push(i);
            color[i] = 1;
            visited[i] = true;
            while(!q.empty()){
                top = q.front();
                q.pop();
                for (int j=lastPos[top];j>=0;j--){
                    if (s[j]-'a'>top){
                        if (color[s[j]-'a']!=-1 && color[s[j]-'a']==color[top])ans =false;
                        else {
                                color[s[j]-'a'] = !color[top];
                                if (!visited[s[j]-'a']){
                                        visited[s[j]-'a']=true;
                                        q.push(s[j]-'a');
                                }
                        }
                    }
                }
            }
        }
    }
    if (ans){
        cout<<"YES"<<endl;
        for (int i=0;i<n;i++){
           cout<<color[s[i]-'a'];

        }
    } else cout<<"NO"<<endl;

    return 0;
}

//https://codeforces.com/contest/1296/problem/E1
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    vector<int> colors(n, 0);

    bool swapped = true;
    bool is_impossible = false;
    while (swapped && !is_impossible)
    {
        swapped = false;
        for (int i = 0; i < n - 1; i++)
        {
            if (s[i] > s[i + 1])
            {
                if ((colors[i] != colors[i + 1]) || (colors[i] == 0 && colors[i + 1] == 0))
                {
                    swap(s[i], s[i + 1]);
                    swap(colors[i], colors[i + 1]);
                    if (colors[i] == 0 && colors[i + 1] == 0)
                    {
                        colors[i] = 1;
                    }
                    swapped = true;
                }
                else
                {
                    is_impossible = true;
                }
            }
        }
    }
    if (!is_impossible)
    {
        cout << "YES"
             << "\n";
        for (int i = 0; i < n; i++)
        {
            cout << colors[i];
        }
    }
    else
    {
        cout << "NO";
    }

    cout << endl;

    return 0;
}

#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];

int main(void)
{
    FAST;

    long long int i=0,j=0,k=0,n=0,m=0,z=0,ns=0,count=0,temp=0;
    long long int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,q=0,sum=0;

    cin>>n;
    string a;
    cin>>a;

    long long int ans[n]={0},b[26]={0};
    b[a[0] - 'a']=1;
    ans[0]=1;
    for(i=1;i<n;i++)
    {
        z=0;
        for(j=a[i]-'a'+1 ; j<26;j++)
        {
            z = max(z,b[j]);
        }

        ans[i]=z+1;
        b[a[i] - 'a']=z+1;
    }

    z=0;

    for(i=0;i<26;i++)
    {
        z=max(z,b[i]);
    }

    if(z<=2){
    cout<<"YES"<<endl;

    for(i=0;i<n;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    }

    else
    {
        cout<<-1<<endl;
    }

}

#include <bits/stdc++.h>

using namespace std;

int TN = 1;

void sol () {

    int n;
    string s;

    cin >> n >> s;

    vector <int> a (n, 0);

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            bool t = 0;
            if (s[j] != s[i]) { t = 1; }
            if (s[j] <= s[i] && t) { a[j] = 1; }
        }
    }

    vector <int> b (n, 0);

    b = a;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (s[j] <= s[i]) {
                ///cout << i << ' ' << j << "pro\n";
                for (int k = i + 1; k < j; ++k) {
                    if (b[k] == b[j] && b[k] != -1) { cout << "NO\n"; return; }
                }
                b[j] = -1;
            }
        }
    }

    cout << "YES\n";

    for (int i = 0; i < n; ++i) { cout << a[i]; }

    cout << '\n';

}

int main () {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ///cin >> TN;

    for (int i = 0; i < TN; ++i) {
        sol ();
    }

    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
map<char, set<char>> mp;
map<char, ll> dp;
bool clash;

void dfs(ll child, ll mark)
{
    dp[child] = mark;
    for (auto c : mp[child])
    {
        if (dp[c] != -1)
        {
            if (dp[c] != mark ^ 1)
            {
                clash = 1;
                return;
            }
        }
        else
        {
            dfs(c, mark ^ 1);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    string s, t;
    cin >> s;
    t = s;
    sort(t.begin(), t.end());
    for (ll i = 0; i < s.size(); i++)
    {
        if (t[i] != s[i])
        {
            mp[t[i]].insert(s[i]);
            mp[s[i]].insert(t[i]);
        }
        dp[t[i]] = -1;
    }
    clash = 0;
    for (auto i : mp)
    {
        if (dp[i.first] == -1)
        {
            dfs(i.first, 0);
        }
    }
    if (clash == 1)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
        for (auto i : s)
        {
            if(dp[i]==-1)
            {
                cout<<0;
            }
            else
            {
                cout << dp[i];
            }
        }
        cout << endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long int
int32_t main(){

//   int t;
//   cin>>t;
//  t=1;
//   while(t--){

      int n;
       cin>>n;

       string s;
       cin>>s;

       int dp[n+1];
       dp[0] = 0;
       int sp[n+1];
        sp[0]=0;

       for(int i = 1 ; i < n ; i++){
        //   cout<<"hi\n";
           if(s[i] < s[i-1])
              dp[i] = 1 - dp[i-1];
           else
            dp[i] =0;

           sp[i] = dp[i];
            // cout<<dp[i];
       }

    //   for(int i = 0; i <n;i++)
        // cout<<dp[i];
        // cout<<endl;

    //   cout<<endl;
      string p = s;
      for(int i = 0 ; i < n*n ; i ++ ){

          for(int j = 0 ; j < n-1; j ++){

              if(s[j] > s[j+1] && dp[j] != dp[j+1])
              {

                //   int temp = dp[j];
                //   dp[j] = dp[j+1];
                //   dp[j+1]=temp;

                  char tem  = s[j];
                  s[j] = s[j+1];
                  s[j+1] = tem;

              }
          }

      }

    //   cout<<s<<endl;
    //   for(int i =0 ;i<n;i++)
        // cout<<dp[i];

      sort(p.begin(),p.end());
      if(p == s)
      {

          cout<<"YES\n";
        //   cout<<n<<endl;
          for(int i = 0; i < n ; i++)
             cout<<sp[i];

      }else
        cout<<"NO\n";

//   }

}

#include<bits/stdc++.h>
//#include<fstream> 		//ofstream mycout("C:/Users/Sevenenen/Desktop/a.txt",ios::app);
//#include<iostream>
//#include<algorithm>		//sort,lower_bound>=,upper_bound>, max...
//#include<vector>
//#include<queue>
//#include<map>
//#include<set>
//#include<deque>
//stl vector,queue,map,set deque,priority_queue<int,vector<int>,greater<int> >先出小，不加默认先出大
//#include<string.h>		//strlen,strcmp...
//#include<string>			//string类
//#include<math.h>			//pow,sqrt,sin,cos
//#include<stdio.h>			//printf,scanf,getchar,gets
//#include<iomanip>			//cout控制
using namespace std;
#define N 200005
#define ll long long
#define MAX INT_MAX/2
#define MOD 1000000007
#define eps 1e-7
#define INF 1e9
struct node
{
	int a,b;
};

int inp[N];
int main()
{
	int n;
	scanf("%d",&n);
	int maxx=0,minn=0,flag=1;
	for(int i=1;i<=n;i++)
	{
		char ch;
		cin>>ch;
		if(ch>=maxx)
		{
			maxx=ch;
		}
		else
		{
			if(minn==0)
				minn=ch;
			if(ch<minn)
				flag=0;
			inp[i]=1;
		}
	}
	if(flag)
	{
		printf("Yes\n");
		for(int i=1;i<=n;i++)
			printf("%d",inp[i]);
	}
	else
		printf("No");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)
        return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}
int main()
{

    fastread();

    ll i,j,n,m,p,sum=0,k,t,a,b,c,d,cnt=0,q,aa,dsasd,sds;

    string str;

    bool flag=true;

    cin>>n;

    cin>>str;

    vector<ll>v[200];

    for(i=0; i<n; i++)
    {
        v[str[i]].eb(i);
    }

    ll ara[n+1]= {-1};
//    vector<ll>v[200];

memset(ara,-1,sizeof(ara));

    for(i=0; i<n; i++)
    {
       if(ara[i]==-1)
        {ara[i]=0;

       for(j=i+1; j<n; j++)
       {
           if(str[i]==str[j])
            ara[j]=ara[i];

           else if(str[j]<str[i])
           {
               if(ara[i]==0)ara[j]=1;

               else ara[j]=0;
           }

       }
        }
    }

    for(i='a'; i<='z'; i++)
    {
        if(v[i].size()>2)
        {
            while(v[i].size()>2)
            {
                v[i].erase(v[i].begin()+1);
            }
        }
    }

    flag=true;

    for(i='a'; i<='z' && flag; i++)
    {
        if(v[i].size()>1)
        {
           // bug;
            for(j=0; j<v[i].size()-1; j++)
            {
                ll l=v[i][j],r=v[i][j+1];

                ll mp[200]={0};

                for(k=l; k<r; k++)
                {
                    if(mp[str[k]-'a'] )
                    {
                        flag=false;

                        break;
                    }
                    mp[str[k]-'a']++;
                }
                if(flag==false)break;

            }
        }

       // cout<<i<<endl;
    }

    if(flag)
    {
        cout<<"YES"<<endl;
        for(i=0; i<n; i++)
            cout<<ara[i];

        cout<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define inf LLONG_MAX
#define mod 1000000007
#define vll vector <ll>
#define pll pair <ll,ll>
#define dbg(n) cout<<n<<' '
#define cu continue
#define br break

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;
	cin>>n;
	string s;
	cin>>s;
	bool a=0,b=0,f=1;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i-1;j>=0;j--)
		{
			if(s[j]>s[i])
			{
				a=1;
				br;
			}
		}
		for(ll j=i+1;j<n;j++)
		{
			if(s[j]<s[i])
			{
				b=1;
				br;
			}
		}
		if(a&&b)
		{
			f=0;
			br;
		}
	}
	if(!f)
		cout<<"NO\n";
	else
	{
		ll ans[n]={0};
		cout<<"YES\n";
		for(ll i=0;i<n;i++)
		{
			for(ll j=i-1;j>=0;j--)
			{
				ans[i]=ans[j]^1;
			}
			cout<<ans[i]<<' ';
		}
		cout<<'\n';
	}
}

   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-8)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v==0) return b;
                                	if(b==0) return v;
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[300100];
                int inv[300010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=((ll)pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=(ll)inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
 //   mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

bool hikaku(pa3 x,pa3 y){
	return x.z<y.z;
}
int ans[200020];
set<int> se[30];

int solve(int y){
	for(int i=0;;i++)if(!se[y].count(i))return i;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

int n;
	cin>>n;
	string s;
	cin>>s;

	int an=0;
	for(int i=0;i<n;i++){
		ans[i]=solve(s[i]-'a');
		for(int j=0;j<s[i]-'a';j++)se[j].insert(ans[i]);
		an=max(an,ans[i]);
	}
	cout<<an+1<<endl;
	if(an+1>2){
		cout<<"NO"<<endl;
	}
	else {
		cout<<"YES"<<endl;
	for(int i=0;i<n;i++)cout<<ans[i];
	cout<<endl;
	}
	/*
		vector<pa3> ku(26,(pa3){inf,-inf,0});

	for(int i=0;i<n;i++){
		ku[s[i]-'a'].x=min(ku[s[i]-'a'].x,i);
		ku[s[i]-'a'].y=max(ku[s[i]-'a'].y,i);

	}
	for(int i=0;i<26;i++)ku[i].z=i;
	sort(ku.begin(),ku.end());
	while(ku.back().x==inf)ku.pop_back();

	int iro[30]={};
	sort(ku.begin(),ku.end(),hikaku);

	int ans=0;
	for(int i=0;i<ku.size();i++){
		set<int> se;
		for(int j=0;j<i;j++){
			if(ku[j].y>ku[i].x){
				se.insert(iro[ku[j].z]);
			}
		}
		for(int j=0;;j++)if(!se.count(j)){
			iro[ku[i].z]=j;
			ans=max(ans,j);
			break;
		}
	}

	cout<<ans+1<<endl;
	*/
	/*
	if(ans+1>2){
		cout<<
	}
	*/

	/*
	for(int i=0;i<26;i++)for(int j=i+1;j<26;j++){
		if(ku[i].first==inf) continue;
		if(ku[j].first==inf) continue;
		if(ku[i].second>ku[j].first)G[i]|=(1<<j),G[j]|=(1<<i);
	}
	for(int i=0;i<26;i++)G[i]|=(1<<i);

	memo[0]=1;
	for(int i=1;i<(1<<26);i++){
		if(i==(i&(-i))){
			memo[i]=2;
			continue;
		}
		int it;
		for(int j=0;;j++)if(i&(1<<j)){
			it=j;
			break;
		}

		int ii=i&((1<<26)-1-G[it]);
		memo[i]=memo[ii]+memo[i^(1<<it)];
	}
	cout<<"d"<<endl;
	for(int er=1;er<30;er++){
	int w=0;
	for(int i=0;i<(1<<26);i++){
		int e=__builtin_popcount(i);
		if(e%2)w+=inf-beki(memo[i],er,inf);
		else w+=beki(memo[i],er,inf);
		w%=inf;
	}
		if(w){
			cout<<er<<endl;
			break;
		}
	}
	*/

	return 0;
 }

#include<bits/stdc++.h>
using namespace std;
int s[205];
char a[205];
int main()
{
	int n;
	cin>>n;
	scanf("%s",a+1);
	s[1]=0;
	for(int i=2;i<=n;i++)
	{
		s[i]=-1;
		for(int j=1;j<i;j++)
		{
			if(a[j]>a[i])
			{
				if(s[j]==s[i])
				{
					cout<<a[j]<<" "<<a[i]<<endl<<j<<" "<<i<<endl;
					cout<<s[j]<<" "<<s[i]<<endl;
					cout<<"NO"<<endl;
					return 0;
				}
				s[i]=!s[j];
			}
		}
		if(s[i]==-1)
		s[i]=0;
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++) cout<<s[i];
 }

#include <bits/stdc++.h>
using namespace std;
int n,l,r,gap;
char s[205],t[205];
int m[205],ans[205],vis[205];
int main()
{
    scanf("%d",&n);
    scanf("%s",s);
    for(int i = 0;i < n;i++)
        t[i] = s[i];
    sort(t,t+n);
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            if (t[i] == s[j]&&!vis[j])
            {
                vis[j] = 1;
                if (i > j)
                {
                    m[j] = i-j;
                    ans[j] = 1;
                }
                else m[j] = j-i;
                break;
            }
        }
    }
//    printf("m:\n");
//    for(int i = 0;i < n;i++) printf("%d ",m[i]);

    int turn = 0,pred,pren;
    pren = pred = -1;
    for(int i = 0;i < n;i++)
    {
        if (m[i])
        {
            if (pred == ans[i])
            {
                if ((pred == 1 && pren-m[i]==2) || (pred == 0 && m[i]-pren==2))
                {
                    printf("NO");
                    return 0;
                }
            }
            if (ans[i]) turn += m[i];
            else turn -= m[i];
        }
        else if (turn)
        {
            printf("NO");
            return 0;
        }
        pred = ans[i];
        pren = m[i];
    }
    printf("YES\n");
    for(int i = 0;i < n;i++) printf("%d",ans[i]);

    return 0;
}

#include <iostream>
#include<map>
#include<vector>
#include <cstring>

//#include <bits/stdc++.h>
#include<unordered_map>

using namespace std;

const int N = 1e7;

void solve(){
    int n; cin >> n;
    string s; cin >> s;
    int res[n];
    int temp[n];
    memset(temp, 0, sizeof(temp));
    memset(res, 0, sizeof(res));
    for (int i = 1; i < n; i ++) {
        if (s[i] < s[i - 1]) {
            int j = i;
            res[i] = 1;
            while(j > 0 && s[j] < s[j - 1]) {
                if (s[j] < s[j - 1] && temp[j - 1] == 1) {
                    cout << "NO";
                    return;
                }
                temp[j] = 0;
                j --;
            }
            temp[j] = 1;
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i ++) {
        if (res[i] != 1) cout << 0;
        else cout << 1;
    }
}

int main() {
        solve();
    return 0;
}

/*input

*/

//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++)
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string fun(string s)
{

	if(sz(s)==0) return "";

	string ans="";
	ll n=sz(s);
	char c = 'z';
	rep(i,0,n) if(s[i]<c) c=s[i];
	// s=c+s;
	// whatis(c);
	ll last_pos=-1;
	string some = "";
	rep(i,0,n)
	{
		if(s[i]==c)
		{
			string r = "";
			rep(j,last_pos+1,i) r+=s[j];
			some+=r;
			if(is_sorted(r.begin(), r.end()))
			{
				rep(j,last_pos+1,i) ans+="1";
				ans+="0";
				last_pos = i;
			}
			else
			{
				cout<<"NO\n";
				exit(0);
			}
		}
	}

	if(!is_sorted(some.begin(), some.end())) {cout<<"NO\n"; exit(0);}
	// whatis(last_pos);
	// whatis(ans);
	string r = "";
	rep(i,last_pos+1,n) r+=s[i];
	string temp = r;
	sort(temp.begin(), temp.end());
	some+=temp;
	if(!is_sorted(some.begin(), some.end())) {cout<<"NO\n"; exit(0);}
	ans+=fun(r);
	return ans;
}

int solve()
{
	ll n;cin>>n;
	string s;cin>>s;
	string ans = fun(s);
	cout<<"YES\n"<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int n;
int a[220];
char s[220];
bool used[220];
vector<int> G[220];
bool vis[220];
int color[220];
struct point
{
	int w,id;
}p[220];
bool b[220][220];
bool tp;
void dfs(int u,int v)
{
	if(tp)
	{
		return;
	}
	if(vis[u])
	{
		return;
	}
	vis[u]=true;
	for(int i=0;i<G[u].size();i++)
	{
		int x=G[u][i];
		if(x!=v)
		{
			if(vis[x])
			{
				tp=true;
				continue;
			}
			dfs(x,u);
		}
	}
}
int main()
{
	cin>>n;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		p[i].w=s[i]-'0';
		p[i].id=i;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)
		{
			if(p[j].w>p[j+1].w)
			{
				swap(p[j].w,p[j+1].w);
				swap(p[j].id,p[j+1].id);
				G[p[j].id].push_back(p[j+1].id);
				G[p[j+1].id].push_back(p[j].id);
				b[p[j].id][p[j+1].id]=true;
				b[p[j+1].id][p[j].id]=true;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		dfs(i,0);
	}
	if(tp)
	{
		printf("NO\n");
	}
	else
	{
		printf("YES\n");
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				if(b[i][j])
				{
					color[j]=(1^color[i]);
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			printf("%d",color[i]);
		}
	}
	return 0;
}

#pragma region
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz size()
#define mem(a,b) memset(a,b,sizeof(a))
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pw(x) (1LL<<(x))
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
#define debug(x)   {cerr <<#x<<" = " <<x<<"\n"; }
#define debuga(a, n) {cerr << #a << " = "; forn(i,n) cerr<<a[i]<<' '; cerr<<endl;}
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define mmax(a,b) a = (a) > (b) ? (a) : (b)
#define mmin(a,b) a = (a) < (b) ? (a) : (b)
#define has(c,x) (c.find(x)!=c.end())

#define rep(i,k,n) for(int (i) = int(k); i < int(n); ++i)
#define IOS ios_base::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<ll, vector<int> > plv;
#define F first
#define S second
#pragma endregion

#define GOOGLE 0

template <typename T> void readv(vector<T> &v, int x) {
	v = vector<T>(x);
	rep(i, 0, x) cin >> (v[i]);
}

/* DATA STRUCTURES */
int n;
string s;
/* ********************** */

/* INPUT */
void _input() {
	cin >> n >> s;
}
/*********************** */

/* SOLVE */
int rand(int a, int b) {
	return a + rand() % (b - a + 1);
}

bool solve() {
	return false;
}

void dfs(int u, vector<vector<int>>& g, vector<int>& sol, vector<bool> &vis) {
	if (vis[u]) return;
	vis[u] = true;
	for (int x : g[u]) {
		sol[x] = 1 - sol[u];
		dfs(x, g, sol, vis);
	}
}

void _solve() {
	vector<int> sol(n, -1);
	rep(i, 0, n) {
		char c = s[i];
		bool l = false, r = false;
		rep(j, 0, i) {
			if (s[j] > c) {
				l = true;
				break;
			}
		}
		rep(j, i + 1, n) {
			if (s[j] < c) {
				r = true;
				break;
			}
		}
		if (l and r) {
			cout << -1 << endl;
			return;
		}
	}
	vector<vector<int>> g(n);

	rep(i, 0, n) {
		char c = s[i];
		rep(j, 0, i) {
			if (s[j] > c) {
				g[i].push_back(j);
				g[j].push_back(i);
			}
		}
	}
	vector<bool> vis(n, false);
	rep(i, 0, n) {
		if (!vis[i]) {
			sol[i] = 1;
			cerr << "dfs " << i << " c = " << s[i] << endl;
			dfs(i, g, sol, vis);
		}
	}
	rep(i, 0, n) {
		for (int x : g[i]) {
			if (sol[i] == sol[x]) {
				cout << -1 << endl;
				return;
			}
		}
	}
	vector<char> v0, v1;
	rep(i, 0, n) {
		if (sol[i] == 0) v0.push_back(s[i]);
		if (sol[i] == 1) v1.push_back(s[i]);
	}
	vector<char> vs = v0;
	sort(vs.begin(), vs.end());
	if (vs != v0) {
		cout << -1 << endl;
		return;
	}
	vs = v1;
	sort(vs.begin(), vs.end());
	if (vs != v1) {
		cout << -1 << endl;
		return;
	}
	cout << "YES" << endl;
	for (auto e : sol) cout << e;
	cout << endl;
}
/* ********************** */

int main()
{
	srand(time((unsigned int)NULL));
	double st = clock();
	//cout.setf( ios_base::unitbuf);
	IOS
	int qq = 1;
	if (GOOGLE) cin >> qq;
	int cc = 0;
	while (cc++ < qq) {
		_input();
		//cout << "Case #" << cc++ << ": ";
		_solve();
	}

	cerr << 1000.0 * (1.0 * clock() - st) / (1.0 * CLOCKS_PER_SEC) << " ms ellapsed\n";
}

//
//  main.cpp
//  gfdsd
//
//  Created by саша on 04.02.2020.
//  Copyright © 2020 саша. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
int main(int argc, const char * argv[]) {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> ans(n, -1), used(n, 0);
    for (int i = 0; i < n; i++) {
        ll q, z = -1;
        q = s[i] - 'a';
        for (int j = i + 1; j < n; j++) {
            ll k;
            k = s[j] -'a';
            if (k < q && used[j] == 0) {
                z = j;
                used[j] = 1;
                q = k;
            }
        }
        if (z > -1) {
            if (ans[i] != -1 ) {
                for (int j = i; j < z; j++) {
                    if (ans[j] == -1) {
                        ans[j] = ans[i];
                    } else if (ans[j] != ans[i]) {
                        cout << "NO" << endl;
                        return 0;
                    }
                }
                if (ans[z] == ans[i]) {
                    cout << "NO" << endl;
                } else {
                    if (ans[i] == 0) {
                        ans[z] = 1;
                    } else {
                        ans[z] = 0;
                    }
                }
            } else {
                for (int j = i; j < z; j++) {
                    ans[j] = 1;
                }
                ans[z] = 0;
            }
            swap(ans[i], ans[z]);
        } else {
            if (ans[i] == -1) {
                ans[i] = 1;
            }
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
        cout << ans[i];
    }
    return 0;
}

#include<iostream>
using namespace std;
char str[250];
int dp[250];
int path[250];
int main(){
    for(int i=0;i<250;i++) path[i]=-1;
    int n;
    cin>>n;
    cin>>str;
    int ans=1;
    int last;
    dp[0]=1;
    for(int i=1;i<n;i++){
        int max=0;
        for(int j=0;j<i;j++){
            if(dp[j]>max&&str[i]<str[j]){
                max=dp[j];
                path[i]=j;
                if(str[i]<str[j]) str[j]='0';
            }}
            dp[i]=max+1;
            if(dp[i]>ans){ans=dp[i];last=i;}
        }
    if(ans<=2) {cout<<"YES"<<endl;for(int i=0;i<n;i++) if(str[i]!='0') str[i]='1';cout<<str;}
    else cout<<"NO";
    return 0;
    }

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
#define trace(x)  cerr << #x << ": " << x << endl;
int main()
{
	fast;
	ll n;cin>>n;string s;cin>>s;vector<ll> ans(n);ans[n-1]=0;ll cur=0;char mini=s[n-1];ll minidx=n-1;
	for(ll i=n-2;i>=0;i--)
	{
		if(s[i]>mini)
		{
			ans[i]=(ans[minidx]+1)%2;cur++;
			if(cur>1){cout<<"NO";return 0;}
		}
		else
		{
			ans[i]=ans[minidx];mini=s[i];minidx=i;cur=0;
		}
	}
	cout<<"YES\n";for(auto u:ans)cout<<u;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define it register int
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
const int maxn=2e5+10;
int n,a[500],b[500]={0};
char s[500];
int main(){
          mem(a,-1);
          scanf("%d",&n);
          scanf("%s",s);
          a[0]=0;
          int ff=1;
          for(it i=1;i<n;i++){
                    int f=1;
                    for(it j=i-1;j>=0;j--){
                                        //cout<<s[i]<<s[j]<<endl;
                              if(s[i]<s[j]){
                                        if(a[i]==-1){
                                                  a[i]=1-a[j];f=0;
                                        }
                                        else{
                                                  if(a[i]==a[j] && b[j]==0){
                                                            ff=0;break;
                                                  }
                                                  else if(a[i]==a[j] && b[j]==1){
                                                            b[j]=0;a[j]=1-a[i];
                                                  }
                                        }
                              }
                    }
                    if(!ff){break;}
                    if(f){a[i]=a[i-1];b[i]=1;}
          }
          if(ff){
                    printf("YES\n");
                    for(it i=0;i<n;i++){
                              printf(i==n-1?"%d\n":"%d",a[i]);
                    }
          }
          else{
                    printf("No\n");
          }
          return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define x1 first
#define y1 second
#define frb(i,a,b) for(int (i)=(a);(i) <= (b); (i)+=(i)&-(i))
#define rfrb(i,a) for(int (i)=(a);(i) > 0;(i)-=(i)&-(i))
#define fr(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rep(i,c) for(auto (i) : (c))
#define mini(a,b) ((a) < (b)) ? (a) : (b)
#define maxi(a,b) ((a) > (b)) ? (a) : (b)
int n;
string a,b;
int ar[200005];
int as[300];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.setf(ios::fixed);cout.precision(0);
    cin>>n>>a;
    b = a;
    sort(b.begin(),b.end());
    int cont = 0;
    fr(i,1,n)if(!as[b[i]]){cont++;as[b[i]]=cont;}
    fr(i,1,n){
        if(i==1){if(a[i-1]!=b[i-1])ar[i] = 1;}
        else{
            if(as[a[i-1]]==as[a[i-2]] || as[a[i-1]]-1==as[a[i-2]])ar[i] = ar[i-1];
            else ar[i] = !ar[i-1];
        }
        if(i>2)
        if(ar[i-1]==1 && as[a[i-1]]<as[a[i-2]]){cout<<"NO";return 0;}
    }
    if(1)cout<<"YES\n";
    fr(i,1,n)cout<<ar[i];
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define PI acos(-1.0)
#define CIR(i, l, u) for(int i = l; i < u; ++i)
#define cir(i, u, l) for(int i = u; i > l; --i)
#define pp(x) cout << x << endl
#define ps(x) cout << "x" << endl
#define pd(x) cout << "*" << x << endl
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define INI(n, i) memset(n, i, sizeof(n))
#define MAX(a, b) a = a > b ? a : b
#define MIN(a, b) a = a < b ? a : b
#define ll long long
const int inf = 0x3f3f3f3f;
//const int maxn = ;

bool isincre(char str[], int len)
{
	--len;
	CIR(i, 0, len) if(str[i + 1] - str[i] < 0) return false;
	return true;
}

int main()
{
	char str[205]; INI(str, 0);
	int len, first = 1;
	cin >> len;
	cin >> str;
	int vis[205], col[205], col_t[205]; INI(vis, 0); INI(col, 0); INI(col_t, 0); vis[0] = 1;

		CIR(i, 1, len)
			{
				if(str[i] < str[i - 1])
				{
//					cout << "*" << endl;

						col[i] = (col[i - 1] + 1) % 2;
						col_t[i] = col[i];
						col_t[i - 1] = col_t[i - 1];

					++i;
				}
				else
				{
//					if(!vis[i])
//					{
						col[i] = col[i - 1];
						col_t[i] = col_t[i - 1];
//					}
				}
			}

	while(1)
	{
		if(isincre(str, len))
		{
			py;
			CIR(i, 0, len) cout << col[i];
			cout << "\n";
			break;
		}

//		int len_t = len - 1;

		CIR(i, 1, len)
		{
			if(str[i] < str[i - 1])
			{
				if(col_t[i] != col_t[i - 1])
				{
					char temp;
					temp = str[i];
					str[i] = str[i - 1];
					str[i - 1] = temp;
					col_t[i] = col_t[i - 1];
					col_t[i - 1] = (col_t[i - 1] + 1) % 2;
				}
				else
				{
					pn;
//					CIR(i, 0, len) cout << col[i];
					return 0;
				}
			}
		}
	}

	return 0;
}

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <map>//<string,int>
#include <math.h>
#include <set>
#include <vector>
#include<sstream>
#define ll long long
#define mod 1000000007
const int INF = 0x3f3f3f3f;
const int NINF = -INF - 1;
const int N=2e5+5;
using namespace std;
char a[N];
int c[N];
int b[26];
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    scanf("%s",a);
    for(int i=0;i<n;i++)
    {
        ans=0;
        for(int j=a[i]-'a'+1;j<26;j++)
        {
            ans=max(ans,b[j]+1);
        }
        b[a[i]-'a']=ans;
        if(ans>2)
        {
            printf("NO\n");
            return 0;
        }
        c[i]=ans-1;
        // printf("%d",c[i]);
    }
     printf("YES\n");
     for(int i=0;i<n;i++) printf("%d",c[i]);
     printf("\n");
    return 0;
}

#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
#define inf ll(1e17)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
#define N 1000001
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
int32_t main()
{  ll i,n,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
   ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   cin>>n ;
   string s ;
   cin>>s ;
   auto s1=s ;
   sort(s1.begin(),s1.end()) ;
   ll arr[n] ;
   for(i=0;i<n;i++)
   {
       arr[i]=-1 ;
   }
   x=0 ;
   bool flag=true ;
   for(i=0;i<n;i++)
   {
       if(s[i]==s1[i])
        {
            if(arr[i]==-1)
                arr[i]=x  ;
            continue ;
        }
        for(j=i+1;j<n;j++)
        {
            if(s[j]==s1[i])
                break ;
        }
        if(arr[j]==-1)
        { arr[j]=x ;
          x=x^1 ; }
          else x=arr[j]^1 ;

        while(j>i)
        {
            if(arr[j-1]==-1)
                arr[j-1]=x ;
            else if(arr[j-1]!=x)
            {
                flag=false ;
                break ;
            }
            swap(s[j],s[j-1]) ;
            swap(arr[j],arr[j-1]) ;
            j-- ;
        }
        x=x^1 ;
        if(!flag)
            break ;
       //x=x^1 ;
        //arr[i]=x ;

   }
  // cout<<s<<" " ;
   if(!flag)
   {
       cout<<"NO\n" ;
       return 0 ;
   }
   cout<<"YES\n" ;
   for(i=0;i<n;i++)
    cout<<arr[i] ;
   return 0; }

#include <bits/stdc++.h>
#define double long double
#define endl '\n'
#define ll long long
using namespace std;

typedef pair<char, char> para;
vector<para> myvec;
ll n;
string s, ans;
bool f = true;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    cin >> s;
    //ans = s;
    for (int i = 0; i < n - 2; i ++)
        if ((s[i] > s[i + 1]) && (s[i + 1] > s[i + 2]))
        {
            cout << "NO";
            return 0;
        }
    s += char((ll)s[n - 1] + 2);
    ans = s;
    for (int i = 0; i < n; i ++)
        if (s[i] <= s[i + 1])
        {
            ans[i] = '0';
            myvec.push_back(make_pair('0', s[i]));
        }
        else
        {
            ans[i] = '1';
            ans[i + 1] = '0';
            myvec.push_back(make_pair('1', s[i]));
            myvec.push_back(make_pair('0', s[i + 1]));
            i ++;
        }
    f = false;
    while (!f)
    {
        f = true;
        for (int i = 0; i < (ll)myvec.size() - 1; i ++)
            if (myvec[i].first > myvec[i + 1].first)
                {
                    f = false;
                    swap(myvec[i], myvec[i + 1]);
                }
    }
    f = true;
    for (int i = 0; i < (ll)myvec.size() - 1; i ++)
        if (myvec[i].second > myvec[i + 1].second)
        {
            f = false;
            break;
        }
    if (!f)
    {
        cout << "NO";
        return 0;
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i ++)
        cout << ans[i];
    return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }
  int random_modul() {

    uniform_int_distribution <int> u1(1e10, 1e11);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

    void solve () {

         /* --------- */
         int a; cin>>a;
    string s;
    cin>>s;
    int m[a];
    for (int i=0;i<a;i++) m[i]=s[i]-'a';
    int dp[a];
    int cur=0;
    vector<vector<int>> last(26);
    for (int i=0;i<a;i++) {
        int q=m[i]; int check=0;
        for (int j=q;j>=0;j--) if (last[j].size()!=0) {dp[i]=dp[last[j][last[j].size()-1]]; last[j].pop_back(); check=1; break; }
        if (check==0) {cur++; dp[i]=cur; }
        last[m[i]].push_back(i);
    }
   if (cur==2) cout<<"YES"; else cout<<"NO";
   if (cur==2) {
       for (int i=0;i<a;i++) cout<<dp[i]-1<<" ";
   }
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);

       //  cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

    //  cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }

#include<bits/stdc++.h>
//#include<fstream> 		//ofstream mycout("C:/Users/Sevenenen/Desktop/a.txt",ios::app);
//#include<iostream>
//#include<algorithm>		//sort,lower_bound>=,upper_bound>, max...
//#include<vector>
//#include<queue>
//#include<map>
//#include<set>
//#include<deque>
//stl vector,queue,map,set deque,priority_queue<int,vector<int>,greater<int> >先出小，不加默认先出大
//#include<string.h>		//strlen,strcmp...
//#include<string>			//string类
//#include<math.h>			//pow,sqrt,sin,cos
//#include<stdio.h>			//printf,scanf,getchar,gets
//#include<iomanip>			//cout控制
using namespace std;
#define N 200005
#define ll long long
#define MAX INT_MAX/2
#define MOD 1000000007
#define eps 1e-7
#define INF 1e9
struct node
{
	int a,b;
};

int inp[N];
int main()
{
	int n;
	scanf("%d",&n);
	int maxx=0,minn=0,flag=1;
	for(int i=1;i<=n;i++)
	{
		char ch;
		cin>>ch;
		if(ch>=maxx)
		{
			maxx=ch;
		}
		else
		{
			if(minn==0)
				minn=ch;
			if(ch<minn)
				flag=0;
			inp[i]=1;
		}
	}
	if(flag)
	{
		printf("Yes\n");
		for(int i=1;i<=n;i++)
			printf("%d",inp[i]);
	}
	else
		printf("No");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define db double
#define vi vector<int>
#define vvi vector<vector<int> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define mem(a,b) memset(a , b , sizeof a ) ;
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mp make_pair
#define all(v) v.begin(),v.end()

#define deb1(a) cout<<"!a="<<a<<endl;
#define deb2(a) cout<<"@a="<<a<<endl;
#define deb3(a) cout<<"#a="<<a<<endl;
#define deb4(a,b) cout<<"$a="<<a<<" and b="<<b<<endl;
#define deb5(a,b) cout<<"%a="<<a<<" and b="<<b<<endl;
#define deb6(a,b) cout<<"^a="<<a<<" and b="<<b<<endl;

int main()
{
	speed
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<set<int> > v(26);
	v[s[0]-'a'].insert(1);
	int col[n];
	mem(col,0);
	col[0]=1;
	int f[26];
	mem(f,0);
	f[s[0]-'a']=1;
	int cnt=1;
	ll ss=0;
	rep(i,0,n)
	{
		if(!f[s[i]-'a']){
			ss++;
			f[s[i]-'a']=1;
		}
	}
//	cout<<"ss="<<ss<<endl;
	mem(f,0);
	rep(i,1,n)
	{
		ll c[26];
		mem(c,1);
		f[s[i]-'a']=1;
		rep(j,s[i]-'a'+1,26)
		{	set<int> ::iterator k;
			for(k=v[j].begin();k!=v[j].end();k++) {

	//	if((i==192||i==54||i==60||i==69||i==77||i==9)&&c[*k]!=0)	cout<<"for i="<<i<<" false "<<*k<<" for "<<(char)('a'+j)<<endl;
			c[*k]=0;
			}
		}
	/*	int z=s[i]-'a'-1;
		while(z>=0&&f[z]==0) z--;

		if(z!=-1&&c[*v[z].begin()]){
			col[i]=*v[z].begin();
			v[s[i]-'a'].insert(col[i]);
			cnt=max(cnt,col[i]);
		//	cout<<"**col["<<i<<"]="<<col[i]<<endl;
			continue;
		}*/
		ll zz=1;
		while(!c[zz]) zz++;
		col[i]=zz;
		v[s[i]-'a'].insert(col[i]);
		//cout<<"$$col["<<i<<"]="<<col[i]<<endl;
		cnt=max(cnt,col[i]);

	}
	if(cnt<=2) {
		cout<<"YES\n";
		rep(i,0,n) cout<<col[i]-1<<" ";
	}
	else cout<<"NO\n";
	//cout<<cnt<<endl;
	//rep(i,0,n) cout<<col[i]<<" ";
//aaabbcbb

}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
//#pragma comment(linker, "/STACK:5000000000")
//#pragma GCC optimize "-O3"
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("mmx,avx,fma")
//#pragma GCC optimize ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e;} return in;}
template <class T>
istream& operator >> (istream& in, vector<pair<T, T> >& v){ for(auto& e : v){ in >> e.first >> e.second;} return in;}

#define int long long
//#define int short int
#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define cont continue
#define ret return
#define For(i, a, b) for (int i = a; i < b;i++)
#define forn(i, a) for (int i = 0;i < a;i++)
#define ford(i, a, b) for (int i = b - 1;i >= a;i--)
#define fordn(i, a) for (int i = a - 1;i >= 0;i--)
#define forr(x, arr) for(auto &x: arr)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define REE(s_) {cout << s_ << '\n';exit(0);}
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#ifdef debug
    #define deb(a) cout << "\n[" << #a << "] == " << a << endl;
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const vector<T>& v){ out << "[";for(int i = 0;i < v.size();i++){out << v[i];if (i != v.size() - 1) out << " ";} out << "]"; return out; }
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const pair<T, T>& v){ out << "[";out << v.first << ", " << v.second;out << "]\n"; return out;}
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const set<T>& v){out << "["; for(auto i = v.begin();i != v.end();i++){ out << *i; if (*i != *v.rbegin()) out << ", ";} out << "]"; return out;}
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const multiset<T>& v){out << "["; for(auto i = v.begin();i != v.end();i++){ out << *i; if (*i != *v.rbegin()) out << ", ";} out << "]"; return out;}
#else
    #define deb(a)
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const vector<T>& v){ for(auto& e : v){ out << e << d;} return out;}
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const pair<T, T> & v){ out << v.X << ' ' << v.Y << '\n'; return out;}
    template <char d = ' ', class T>
    ostream& operator << (ostream& out, const set<T>& v){ for(auto& e : v){ out << e << d;} return out;}
#endif
typedef long long ll;
typedef long double ldd;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef unordered_map<string, int> msi;
typedef set<int> si;
typedef set<pii> spii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <typename T> string toString(T val){ostringstream oss; oss << val; return oss.str();}
template<typename T> T sqr(T a) {return a * a;}
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
//const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
//const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1};
//const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2};
//const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1};
const ldd eps = 1e-7;
const int mod = (int)1e9 + 7;
//const int MAX_MEM = 1e8;
//int mpos = 0;
//char mem[MAX_MEM];
//inline void * operator new ( size_t n ) {
//    assert((mpos += n) <= MAX_MEM);
//    return (void *)(mem + mpos - n);
//}
//inline void operator delete ( void * ) noexcept { }
//int mulq(int a, int b, int mod){
//    int res = 0;
//    while(b){
//        if (b & 1){
//            (res += a) %= mod;
//        }
//        b >>= 1;
//        (a += a) %= mod;
//    }
//    return res;
//}
//
//int powq(int a, int b, int mod) {
//    int res = 1;
//
//    while(b){
//        if (b & 1){
//            res = mulq(res, a, mod);
//        }
//        b >>= 1ll;
//        a = mulq(a, a, mod);
//    }
//    return res;
//}

void solve(){
    int n;
    cin >> n;
    vi a(n);
    forn(i, n){
        char x;
        cin >> x;
        a[i] = x - 'a';
    }
    deb(a);
    vi color(n, -1);
    map<int, vi> mp;
    vi was(n, 0);
    iota(all(was), 0ll);
    forn(i, n){
        For(j, i + 1, n){
            if (a[j] < a[i]){
                if (color[i] == -1 && color[j] == -1){
                    color[i] = 0;
                    color[j] = 1;
                }
                else if (color[i] != -1 && color[i] != -1){
                    if (color[i] == color[j]) {
                        cout << "NO\n";
                        return;
                    }

                }
                else if (color[i] == -1){
                    if (color[j] == 1) color[i] = 0;
                    else color[i] = 1;
                }
                else if (color[j] == -1){
                    if (color[i] == 1) color[j] = 0;
                    else color[j] = 1;
                }
                swap(a[j], a[i]);
                swap(color[i], color[j]);
                swap(was[i], was[j]);
                mp[i].pb(j);
            }
        }
        if (color[i] == -1) color[i] = 0;
//        deb(a);
    }
//    deb(a);
//    deb(color);
//    deb(was);
    vi ans(n);
    forn(i, n){
        ans[i] = color[was[i]];
    }
    cout << "YES\n";
    forr(i, ans){
        cout << i;
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #ifdef KULA
            freopen("input.txt", "r", stdin);
//            freopen("output.txt", "w", stdout);
    #else
//            freopen("king2.in", "r", stdin);
//            freopen("king2.out", "w", stdout);
    #endif

    int t;
    t = 1;
//    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
namespace yspm{
	inline int read()
	{
		int res=0,f=1; char k;
		while(!isdigit(k=getchar())) if(k=='-') f=-1;
		while(isdigit(k)) res=res*10+k-'0',k=getchar();
		return res*f;
	}
	const int N=1e5+10;
	int ans[N],fl[N];
	signed main()
	{
		int len=read(); string s;
		cin>>s; fl[1]=1; ans[1]=0;
		for(int i=2;i<=len;++i)
		{
			if(s[i-1]>=s[i-2]) ans[i]=ans[i-1],fl[i]=1;
			else
			{
				if(!fl[i-1]) return cout<<"NO"<<endl,0;
				fl[i]=0; ans[i]=!ans[i-1];
			}
		}
		puts("YES")	; for(int i=1;i<=len;++i) cout<<ans[i]; cout<<endl;
		return 0;
	}
}
signed main(){return yspm::main();}

#include <cassert>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

const int mxN = 200;
int color[mxN];
vector<int> adj[mxN];

bool set_color(int node, int c) {
	color[node] = c;
	for (int v : adj[node]) {
		if ((color[v] == c) || (color[v] == -1 && !set_color(v, !c))) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	memset(color, -1, mxN);
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] > s[j]) {
				adj[i].push_back(j);
				adj[j].push_back(i);
			}
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (color[i] == -1) {
			if (!set_color(i, 0)) {
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES\n";
	for (int i = 0; i < n; i++) {
		assert(color[i] == 0 || color[i] == 1);
		cout << color[i];
	}
}

#include <iostream>
#include <string>

using namespace std;

const int NMAX = 2e5;
const int SIGMA = 26;

int N;
string s;

int v[NMAX + 5], color[NMAX + 5], dp[SIGMA + 5];

int main()
{
    cin >> N >> s;

    for(int i = 0; i < N; i++)
        v[i] = s[i] - 'a';

    for(int i = N - 1; i >= 0; i--)
        {
            int r = 0;

            for(int j = 0; j <= v[i]; j++)
                r = max(r, dp[j]);

            color[i] = r + 1;

            dp[v[i]] = color[i];
        }

    int mx = 0;

    for(int i = 0; i < N; i++)
        mx = max(mx, color[i]);

    if(mx > 2)
        cout << "NO\n";
    else
    {
        cout << "YES\n";

        for(int i = 0; i < N; i++)
            cout << color[i] - 1;
    }

    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>,
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;

class BIT{
    vector<long int> vec;
    public:
        BIT(long int n){
            vec.resize(n);
        }

        void update(long int idx, long int val){
            for(; idx < vec.size(); idx += idx & (-idx))
                vec[idx] += val;
        }

        long int query(long int b){
            long int result = 0;
            while(b){
                result += vec[b];
                b -= b & (-b);
            }
            return result;
        }

        void print(){
            for(auto ele : vec)
                cout<<ele<<" ";
            cout<<endl;
        }
};

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif

   long int n;
   cin>>n;

   vector<long int> ans(n);
   ht dp;
   for(long int i = 0; i < n; i++){
      char c;
      cin>>c;
      long int num = c - 'a';
      for(long int j = num + 1; j < 26; j++)
         ans[i] = max({dp[j] + 1,1LL});

      dp[num] = max(ans[i],dp[num]);
   }

   long int maxe = *max_element(ans.begin(),ans.end());

   if(maxe > 1)
      cout<<"NO\n";
   else{
      cout<<"YES\n";
      for(auto ele : ans)
         cout<<ele;
   }
   return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 1000000007
#define vc vector
#define vci vector<ll>
#define si set<ll>
#define pb push_back
#define pop pop_back
#define mii map<ll,ll>
#define pii pair<ll,ll>
#define msi map<string,ll>
#define PI 3.14159265
#define r0 return 0
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    string s,t;
    cin>>s;
    t=s;
    sort(t.begin(),t.end());
    ll a[n],b[n];
    a[0]=0;
    b[0]=0;
    ll x,z;
    rep(i,1,n)
    {
        if(s[i]<s[i-1])
        {
            a[i]=!a[i-1];
            b[i]=!b[i-1];
            x=i-1;
            while(x>=0&&s[i]<s[x])
            {
                if(a[i]==a[x])
                {
                    cout<<"NO";
                    r0;
                }
                x--;
            }
            z=a[i];
            for(ll j=i;j>x+1;j--)
            {
                a[j]=a[j-1];
            }
            a[x+1]=z;
        }
        else
        {
            a[i]=a[i-1];
            b[i]=b[i-1];
        }
    }
    cout<<"YES"<<endl;
    rep(i,0,n)
    {
      cout<<b[i];
    }
    return 0;

}

#include <bits/stdc++.h>
#define int long long
#define lb(a) ((a)&(-a))
using namespace std;

const int maxn=2e2+10;

int n;

string s;

vector <int> adg[maxn];

//set < pair<char,int>

//set<pair <char,int> ::iterator it;

int h[maxn],mark[maxn],l[maxn];

bool l1;

void dfs(int v)
{
    mark[v]=1;
    for(int i=0;i<adg[v].size();i++)
    {
        int u=adg[v][i];
        if(!mark[u])
        {
            l[u]=((l[v]+1)%2);
            h[u]=h[v]+1;
            dfs(u);
        }
    }
   // cout<<v<<endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
       // if(cin.peek()!='\n')
 //   ifstream cin("input.txt");
 //   ofstream cout("output.txt");
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
         for(int j=i+1;j<n;j++)
         {
             if(s[i]>s[j])
             {
                // cout<<"evesvsersv";
                  adg[i].push_back(j);
                  adg[j].push_back(i);
             }
         }
    }
    for(int i=0;i<n;i++)
        if(!mark[i])
        dfs(i);
    if(l1==1)
        cout<<"NO";
    else{
            cout<<"YES"<<endl;
        for(int i=0;i<s.size();i++)
        {
            cout<<l[i];
        }
    }
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n; cin>>n;
    char s[n], t;
    ll o[n]; o[0]=0;
    for (ll i=0; i<n; i+=1)cin>>s[i];
    t = 'a';    ll j=0;

     for (ll i=1; i<n; i+=1)
     {
         if(s[i] < s[i-1])
         {
             if(s[i]<t)j++;
             o[i]=1;
         }
         else o[i]=0;
     }

      if(j>0)cout<<"NO";
      else
      {
          cout<<"YES"<<endl;
          for (ll i=0; i<n; i+=1)cout<<o[i];
      }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {

	    int n;
	    cin>>n;

	    string s;
	    cin>>s;
	    int a[n];
	    a[0] = 0;
	    for(int i = 0;i<n-1;i++){
	        if(s[i] >s[i+1]){
	            a[i+1] = 1;

	        }
	        else if(a[i] == 1 && s[i]==s[i+1]){
	            a[i+1] = 1;

	        }
	        else{
	            a[i+1] = 0;
	        }
	    }
	    int flag = 0;
	    for(int i=0;i<n-1;i++){
	        if(a[i]==1 && a[i+1]==1){
	            if(s[i]!=s[i+1]){
	                cout<<"NO"<<endl;
	                flag =1;
	            }
	        }
	    }
	    if(flag==0){
	    cout<<"YES"<<endl;
	    for(int i=0;i<n;i++){
	        cout<<a[i];
	    }
	    cout<<endl;

	    }

	return 0;
}

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define pb push_back
#define fi first
#define se second
#define lowbit(x) x&(-x)
#define PII pair<int, int>
#define mst(a, b) memset(a, b, sizeof(a))
#define rush() int T;scanf("%d", &T);for(int cas = 1; cas <= T; cas++)
#define Rush() int T; cin >> T; for(int cas = 1; cas <= T; cas++)
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef double db;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int Mod = 1e9 + 7;
const int MaxN = 2e5 + 5;

char s[205];
int a[205], dp[205], path[205];
int ans[205], f[205];

int main()
{
	int n;
	scanf("%d %s", &n, s + 1);
	for(int i = 1; i <= n; i++) a[i] = s[i] - 'a' + 1;
	int len = 1;
	dp[1] = a[1], path[1] = len;
	for(int i = 2; i <= n; i++) {
		 if(a[i] > dp[len]) {
		 	  dp[++len] = a[i];
		 	  path[i] = len;
		 }
		 else {
		 	  int pos = lower_bound(dp + 1, dp + 1 + len, a[i]) - dp;
		 	  dp[pos] = a[i], path[i] = pos;
		 }
	}
	// cout << "len == " << len << endl;
	int Max = INF;
	for(int i = n; i > 0 && len; i--) {
		if(path[i] == len && Max > a[i]) {
			ans[len--] = i;
			Max = a[i];
		}
	}
	for(int i = 1; i <= n; i++) if(ans[i]) f[ans[i]] = 1;
	int flag = 1, pre = 0;
	for(int i = 1; i <= n && flag; i++) {
		if(!f[i]) {
			if(pre && a[i] < pre) flag = 0;
			pre = a[i];
		}
	}
	if(flag) {
		printf("YES\n");
		for(int i = 1; i <= n; i++) printf("%d", !f[i]);
	}
	else printf("NO");
	printf("\n");
	return 0;
}

#pragma region
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz size()
#define mem(a,b) memset(a,b,sizeof(a))
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pw(x) (1LL<<(x))
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
#define debug(x)   {cerr <<#x<<" = " <<x<<"\n"; }
#define debuga(a, n) {cerr << #a << " = "; forn(i,n) cerr<<a[i]<<' '; cerr<<endl;}
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define mmax(a,b) a = (a) > (b) ? (a) : (b)
#define mmin(a,b) a = (a) < (b) ? (a) : (b)
#define has(c,x) (c.find(x)!=c.end())

#define rep(i,k,n) for(int (i) = int(k); i < int(n); ++i)
#define IOS ios_base::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<ll, vector<int> > plv;
#define F first
#define S second
#pragma endregion

#define GOOGLE 0

template <typename T> void readv(vector<T> &v, int x) {
	v = vector<T>(x);
	rep(i, 0, x) cin >> (v[i]);
}

/* DATA STRUCTURES */
int n;
string s;
/* ********************** */

/* INPUT */
void _input() {
	cin >> n >> s;
}
/*********************** */

/* SOLVE */
int rand(int a, int b) {
	return a + rand() % (b - a + 1);
}

bool solve() {
	return false;
}

void dfs(int u, vector<vector<int>>& g, vector<int>& sol, vector<bool> &vis) {
	if (vis[u]) return;
	vis[u] = true;
	for (int x : g[u]) {
		sol[x] = 1 - sol[u];
		dfs(x, g, sol, vis);
	}
}

void _solve() {
	vector<int> sol(n, -1);
	rep(i, 0, n) {
		char c = s[i];
		bool l = false, r = false;
		rep(j, 0, i) {
			if (s[j] > c) {
				l = true;
				break;
			}
		}
		rep(j, i + 1, n) {
			if (s[j] < c) {
				r = true;
				break;
			}
		}
		if (l and r) {
			cout << -1 << endl;
			return;
		}
	}
	vector<vector<int>> g(n);

	rep(i, 0, n) {
		char c = s[i];
		int z = 0, o = 0;
		rep(j, 0, i) {
			if (s[j] > c) {
				g[i].push_back(j);
			}
		}
		rep(j, i + 1, n) {
			if (s[j] < c) {
				g[i].push_back(j);
			}
		}
	}
	vector<bool> vis(n, false);
	rep(i, 0, n) {
		if (!vis[i]) {
			sol[i] = 0;
			dfs(i, g, sol, vis);
		}
	}
	rep(i, 0, n) {
		for (int x : g[i]) {
			if (sol[i] == sol[x]) {
				cout << -1 << endl;
				return;
			}
		}
	}

	cout << "YES" << endl;
	for (auto e : sol) cout << e;
	cout << endl;
}
/* ********************** */

int main()
{
	srand(time((unsigned int)NULL));
	double st = clock();
	//cout.setf( ios_base::unitbuf);
	IOS
	int qq = 1;
	if (GOOGLE) cin >> qq;
	int cc = 0;
	while (cc++ < qq) {
		_input();
		//cout << "Case #" << cc++ << ": ";
		_solve();
	}

	cerr << 1000.0 * (1.0 * clock() - st) / (1.0 * CLOCKS_PER_SEC) << " ms ellapsed\n";
}

#include <bits/stdc++.h>
//E2
using namespace std;
char str[200007];
int ans[200007];
int bf[26];

int main() {
    int n;
    scanf("%d%s", &n, str);
    int ansa = 0;
    for (int i = 0; str[i]; i++) {
        int t = str[i] - 'a';
        for (int j = t; j >= 0; j--) {
            if (bf[j]) {
                if (j != t) {
                    bf[t] = bf[j];
                    bf[j] = 0;
                }
                break;
            }
        }
        if (!bf[t]) {
            bf[t] = ++ansa;
        }
        ans[i]=bf[t];
    }
    if(ansa<2){
        printf("YES\n");
        for (int i = 0; str[i]; i++) {
            printf("%d", ans[i]+1);
        }
    }
    else{
        printf("NO");
    }
    puts("");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans[n],rez[n];
    for (int c = 0; c < n; c++)
        ans[c] = 0,rez[c] = 0;

    bool posibil = true;
    for (int c = 1; c < n; c++){

        int p = c; bool dif = false;
        for (int c2 = c - 1; c2 >= 0; c2--){
            if ((s[c] < s[c2]) || (s[c] == s[c2] && dif && s[c2] != s[c2 + 1])){
                if (s[c] == s[c2])
                    p = c2 + 1; else
                p = c2;
            }
            if (s[c] != s[c2])
                dif = true;
        }

        if (p != c)
            while (s[p] == s[p + 1])
                p++;

        if (p != c){
            ans[c] = 1;
            rez[c] = 1;
            for (int c2 = c; c2 > p; c2--)
            if (ans[c2] != ans[c2 - 1]){

                swap(s[c2],s[c2 - 1]);

                ans[c2] = 0;
                ans[c2 - 1] = 1;

            } else
            posibil = false;
        }

    }

    if (posibil){
        cout << "YES" << endl;
        for (int c = 0; c < n; c++)
        cout << rez[c];
    } else
    cout << "NO";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define All(x) x.begin() , x.end()
#define mem(aa,x) memset(aa,x,sizeof aa)
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
const int maxn=205;

vi v[maxn];
int ans[maxn];
bool visit[maxn];

bool dfs(int now,bool color){
	//cout<<"test"<<now<<" "<<color<<"\n";

	if(ans[now]==!color) return 0;
	if(visit[now]) return 1;

	ans[now]=color;
	visit[now]=1;

	for(auto i:v[now])
		if(!dfs(i,!color))
			return 0;

	return 1;
}

main(){IOS
	int n;
	string s;
	cin>>n>>s;
	rep(i,0,n-1)
		rep(j,i+1,n-1)
			if(s[i]>s[j]){
				v[i].pb(j);
				v[j].pb(i);
			}
	mem(ans,-1);
	mem(visit,0);

	rep(i,0,n-1){
		if(ans[i]==-1){
			if(!dfs(i,0)){
				puts("NO");
				return 0;
			}
		}
	}

	puts("YES");
	rep(i,0,n-1) cout<<ans[i];
	cout<<"\n";
}

#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

map < pair < char , int > , int > m ;

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;

    int n ;
    string s ;
    cin >> n ;
    cin >> s ;
    string firstt = s ;
    vector < int > q(n , 0) ;
    for(int i = 0 ; i < n ; i++){
        m[{s[i] , i}] = -1 ;
    }
    int f = 0 ;
    m[{s[0] , 0}] = 0 ;
    while(true){
        f = 0 ;
        for(int i = 1 ; i < n ; i++){
            //cout << "index = " << i << " " << "char = " << s[i] << " " << m[{s[i] , i}] << endl << endl ;
            if((int)(s[i]) < (int)(s[i - 1])){
                f = 1 ;
                if(m[{s[i] , i}] == m[{s[i - 1] , i - 1}] and m[{s[i] , i}] != -1 and m[{s[i - 1] , i - 1}] != -1){
                    cout << "NO" << endl ;
                    return 0 ;
                }
                else{
                    m[{s[i] , i}] = 0 ;
                    m[{s[i - 1] , i - 1}] = 1 ;
                    q[i] = 1 ;
                    q[i - 1] = 0 ;
                    char t = s[i] ;
                    char p = s[i - 1] ;
                    int x = m[{s[i] , i}] ;
                    int y = m[{s[i - 1] , i - 1}] ;
                    s[i - 1] = t ;
                    s[i] = p ;
                    m[{t , i - 1}] = x ;
                    m[{p , i}] = y ;
                }
            }
                //cout << "index = " << i << " " << "char = " << s[i] << " " << m[{s[i] , i}] << endl << endl ;
        }
        if(!f){
            break ;
        }
    }
    cout << "YES" << endl ;
    vector <int> w(n , 0) ;
    for(int i = 0 ; i < firstt.size() ; i++){
        for(int j = 0 ; j < s.size() ; j++){
            if(firstt[i] == s[j]){
                w[i] = q[j] ;
                s[i] = 'x' ;
                break ;
            }
        }
    }
    for(auto i : w){
        cout << i ;
    }
    return 0 ;
}

#include <bits/stdc++.h>
using namespace std;
#define xx first
#define yy second
const int mod = 1000000007;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N, seg[200005 * 4], ans[200005];
string S;
pii arr[200005];
void update(int n, int k) {
	while (n != 0) {
		seg[n] |= k;
		n /= 2;
	}
}
int get(int s, int e) {
	int v = 1;
	while (s <= e) {
		if (s % 2 == 1) {
			v |= seg[s++];
		}
		if (e % 2 == 0) {
			v |= seg[e--];
		}
		s /= 2; e /= 2;
	}
	int ret = 0;
	v /= 2;
	while (v != 0) {
		if (v % 2 == 1) {
			ret++;
		}
		v /= 2;
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> S;
	for (int i = 0; i < S.length(); i++) {
		arr[i] = { S[i] - 'a',i };
	}
	sort(arr, arr + N);
	reverse(arr, arr + N);
	int s = 1;
	while (s <= N) s *= 2;
	s--;
	int maxV = 0;
	for (int i = 0; i < N; i++) {
		int v = get(s + 1, s + arr[i].yy + 1);
		ans[arr[i].yy] = v + 1;
		maxV = max(maxV, v + 1);
		update(s + arr[i].yy + 1, (1 << v + 1));
	}
	if (maxV >= 3)cout << "NO\n";
	else {
		cout << maxV << "\n";
		for (int i = 0; i < N; i++) {
			cout << ans[i] - 1<< " ";
		}
	}
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const int INF = 2e9;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

struct Trace {
    int prev, c1, c2, col;
};

int n;
string s;
bool f[205][30][30][2];
Trace trace[205][30][30][2];
bool res[205];

void solveProblem() {
    //f[i][c1][c2]: pos i, last character in s1 is c1, s2 is c2;

    s = ' ' + s;
    REP(i, 0, n) REP(j, 0, 25) REP(k, 0, 25) REP(l, 0, 1) f[i][j][k][l] = false;

    f[0][0][0][0] = true;
    REP(i, 0, n - 1) {
        REP(c1, 0, 25) {
            REP(c2, 0, 25) {
                REP(k, 0, 1) {
                    if (!f[i][c1][c2][k]) continue;
                    int nxt = s[i + 1] - 'a';

                    if (nxt >= c1) {
                        f[i + 1][nxt][c2][0] = true;
                        trace[i + 1][nxt][c2][0] = {i, c1, c2, k};
                    }

                    if (nxt >= c2) {
                        f[i + 1][c1][nxt][1] = true;
                        trace[i + 1][c1][nxt][1] = {i, c1, c2, k};
                    }
                }
            }
        }
    }

    bool ans = false;
    int pos, last1, last2, curColor;
    REP(c1, 0, 25) REP(c2, 0, 25) REP(l, 0, 1) {
        ans |= f[n][c1][c2][l];
        if (f[n][c1][c2][l]) {
            pos = n, last1 = c1, last2 = c2, curColor = l;
        }
    }

    //cerr << pos << " " << last1 << " " << last2 << " " << curColor << endl;
    cout << (ans ? "YES" : "NO") << endl;
    if (!ans) return;

    while (pos >= 1) {
        res[pos] = curColor;
        int t1 = pos, t2 = last1, t3 = last2, t4 = curColor;
        pos = trace[t1][t2][t3][t4].prev;
        last1 = trace[t1][t2][t3][t4].c1;
        last2 = trace[t1][t2][t3][t4].c2;
        curColor = trace[t1][t2][t3][t4].col;
    }

    if (ans) REP(i, 1, n) cout << res[i] << " ";
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n;
    cin >> s;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}

#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;

int main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
	#endif
	int n;
	string s, res;
	char lst0 = 'a', lst1 = 'a';
	cin>>n>>s;
	for(int i = 0; i < n; i++){
		if(s[i] >= lst0){
			res += '0';
			lst0 = s[i];
		}
		else if(s[i] >= lst1){
			res += '1';
			lst1 = s[i];
		}
		else{
			cout<<"NO"<<endl;
			break;
		}
	}
	cout<<"YES"<<endl;
	cout<<res<<endl;
	return 0;
}

#include <bits/stdc++.h>
//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;

    vector <ll> maxv;
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x)%mod;

        res %= mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}

#define SIEVE_SIZE 5000000+10
bool sieve[SIEVE_SIZE];
void make_sieve(){
    for(int i=0; i<SIEVE_SIZE; ++i) sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for(int i=2; i*i<SIEVE_SIZE; ++i) if(sieve[i]) for(int j=2; i*j<SIEVE_SIZE; ++j) sieve[i*j] = false;
}

bool isprime(ll n){
    if(n == 0 || n == 1) return false;
    for(ll i=2; i*i<=n; ++i) if(n%i==0) return false;
    return true;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
ll GCD(ll a, ll b){

    if(b == 0) return a;
    return GCD(b, a%b);
}

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int arr[210];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    int n; cin >> n;

    string s; cin >> s;

    string t = s;
    string ss = s;
    sort(all(t));

    bool ok = true;
    for(int i=0; i<n; i++){

        if(s[i] == t[i]) continue;
        int idx = 0;
        for(int j=i+1; j<n; j++){
            if(arr[j]==1){
                ok = false;
            }
            if(t[i] == s[j]){
                idx = j;
                break;
            }
        }

        arr[idx] = 1;
        for(int j=idx-1; j>=i; --j){
            swap(s[j], s[j+1]);
        }
        //cout << s << endl;
    }

    if(ok){
        cout << "YES" << endl;
        for(int i=0; i<n; i++){
            cout << arr[i];
        }
        cout << endl;
        return 0;
    }

    memset(arr, 0, sizeof(arr));
    s = ss;

    ok = true;
    for(int i=n-1; i>=0; --i){

        int idx = 0;
        if(t[i] == s[i]) continue;
        for(int j=i-1; j>=0; --j){
            if(arr[j] == 1){
                ok = false;
            }

            if(t[i] == s[j]){
                idx = j;
                break;
            }
        }

        arr[idx] = 1;
        for(int j=idx+1; j<=i; ++j){
            swap(s[j], s[j-1]);
        }
    }

    if(ok){
        cout << "YES" << endl;
        for(int i=0; i<n; i++){
            cout << arr[i];
        }
        cout << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>

#pragma comment(linker, "/STACK:36777216")

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout.precision(20); cout.setf(ios::fixed);
	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<int>clr(n, -1);
	vector<int>p(n);
	iota(all(p), 0);

	for (int i = 1; i < n; i++) {
		if (s[p[i]] >= s[p[i - 1]]) continue;
		int j = i;
		while (j > 0 && s[p[j]] < s[p[j - 1]]) {
			if (clr[p[j - 1]] != -1) {
				if (clr[p[j]] == clr[p[j - 1]]) {
					cout << "NO\n";
					return 0;
				}

				if (clr[p[j]] == -1) clr[p[j]] = clr[p[j - 1]] ^ 1;
			}
			else {
				if (clr[p[j]] == -1) {
					clr[p[j]] = 0;
				}

				clr[p[j - 1]] = clr[p[j]] ^ 1;
			}

			swap(s[p[j]], s[p[j - 1]]);
			swap(p[j], p[j - 1]);
			j--;
		}
	}

	cout << "YES\n";
	vector<int>ans(n);
	for (int i = 0; i < n; i++) {
		if (clr[i] == -1) clr[i] = 0;
		cout << clr[i];
		ans[p[i]] = clr[i];
	}

	//cout << '\n';
	//for (auto& x : ans) cout << x;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll n; cin>>n;
    char s[n], t;
    ll o[n]; o[0]=0;
    for (ll i=0; i<n; i+=1)cin>>s[i];
    t = 'a';    ll j=0;  ll max = s[0];

     for (ll i=1; i<n; i+=1)
     {
        if(s[i] < max)
         {
             o[i]=1;
             if(s[i]<t)j++;
             t=s[i];
         }
         else if  (s[i] == max)o[i]=o[i-1];
         else
         {
             o[i]=0;
             max = s[i];
         }
     }

      if(j>0)cout<<o[7];
      else
      {
          cout<<"YES"<<endl;
          for (ll i=0; i<n; i+=1)cout<<o[i];
      }
    return 0;
}

//
//  main.cpp
//  gfdsd
//
//  Created by саша on 04.02.2020.
//  Copyright © 2020 саша. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
int main(int argc, const char * argv[]) {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> ans(n, -1), used(n, 0);
    for (int i = 0; i < n; i++) {
        ll q, z = -1;
        q = s[i] - 'a';
        for (int j = i + 1; j < n; j++) {
            ll k;
            k = s[j] -'a';
            if (k < q && used[j] == 0) {
                z = j;
                used[j] = 1;
                q = k;
            }
        }
        if (z > -1) {
            if (ans[i] != -1 ) {
                for (int j = i; j < z; j++) {
                    if (ans[j] == -1) {
                        ans[j] = ans[i];
                    } else if (ans[j] != ans[i]) {
                        cout << "NO" << endl;
                        return 0;
                    }
                }
                if (ans[z] == ans[i]) {
                    cout << "NO" << endl;
                    return 0;
                } else {
                    if (ans[i] == 0) {
                        ans[z] = 1;
                    } else {
                        ans[z] = 0;
                    }
                }
            } else {
                for (int j = i; j < z; j++) {
                    ans[j] = 1;
                }
                ans[z] = 0;
            }
            swap(ans[i], ans[z]);
        } else {
            if (ans[i] == -1) {
                ans[i] = 1;
            }
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
        cout << ans[i];
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define DIM 200007
#define DIMM 37
#define INF 1000000007

typedef long long ll;
typedef pair<ll,ll> pllll;
typedef string str;
typedef char cr;

ll n;
str s;
ll cc;
ll mc[DIMM];
ll res,c[DIM];

int main()
{
    ios_base::sync_with_stdio();
    cin.tie();
    cout.tie();

    //freopen("input.txt","r",stdin);

    cin>>n>>s;

    res=1;
    c[1]=1;
    mc[s[0]-'a']=1;

    for(int i=1;i<n;i++){
     cc=0;
     for(int j=(s[i]-'a'+1);j<26;j++)cc=max(cc,mc[j]);

     c[i+1]=cc+1;
     mc[s[i]-'a']=max(mc[s[i]-'a'],c[i+1]);
     res=max(res,c[i+1]);
    }

    cout<<res<<endl;
    for(int i=1;i<=n;i++)cout<<c[i]<<' ';
    cout<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define x1 first
#define y1 second
#define frb(i,a,b) for(int (i)=(a);(i) <= (b); (i)+=(i)&-(i))
#define rfrb(i,a) for(int (i)=(a);(i) > 0;(i)-=(i)&-(i))
#define fr(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rep(i,c) for(auto (i) : (c))
#define mini(a,b) ((a) < (b)) ? (a) : (b)
#define maxi(a,b) ((a) > (b)) ? (a) : (b)
int n;
string a,b;
int ar[200005];
int as[300];
char maxs;
char maxs1;
int id;
int id1;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.setf(ios::fixed);cout.precision(0);
    cin>>n>>a;
    b = a;
    sort(b.begin(),b.end());
    int cont = 0;
    fr(i,1,n)if(!as[b[i]]){cont++;as[b[i]]=cont;}
    fr(i,1,n){
        if(i==1){if(a[i-1]!=b[i-1])ar[i] = 1;}
        else{
            if(as[a[i-1]]==as[a[i-2]] || as[a[i-1]]-1==as[a[i-2]])ar[i] = ar[i-1];
            else ar[i] = !ar[i-1];
        }
        if(ar[i]==1){
            if(maxs < a[i-1]){
                maxs = a[i-1];
                id = as[a[i-1]];
            }
        }
        else{
            if(maxs1 < a[i-1]){
                maxs1 = a[i-1];
                id1 = as[a[i-1]];
            }
        }
        if(as[a[i-1]]<as[a[i-2]]){
            if(ar[i-1]==1 && maxs1!='0' && id1 > as[a[i-1]]){cout<<"NO";return 0;}
            if(ar[i-1]==0 && maxs!='0' && id > as[a[i-1]]){cout<<"NO";return 0;}
        }
    }
    cout<<"YES\n";
    fr(i,1,n)cout<<ar[i];
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <string.h> // memset
#include <algorithm> // lower_bound
#include <iomanip>
    // #include <bits/stdc++.h>

using namespace std;

#define fs first
#define sd second
#define pb push_back
#define vii vector<int>
#define pii pair<int, int>
#define MAXN 120000

const int INF = 0x3f3f3f3f;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string s, ans;
    cin >> n >> s;
    ans.push_back('0');
    for(int i = 1; i < (int)s.size(); ++i) {
        if(s[i-1] <= s[i])
            ans.push_back(ans[i-1]);
        else {
            if(ans[i-1] == '1' && s[i-1] > s[i]) {
                cout << "NO\n";
                return 0;
            }
            ans.push_back('1');

        }
    }

    cout << "YES\n" << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
static bool used[1000000 + 110];
static char    s[1000000 + 110];
vector<ll> doit()
  {
  	vector<ll> v;
  	static ll len[300];
  	static ll pre[300];
  	memset(len,0,sizeof(len));
  	memset(pre,0,sizeof(pre));
  	for (ll i = 0;s[i];i++)
  	  if (used[i] == 0)
  	    {
  	    	len[i] = 1;
  	    	pre[i] = -1;
  	    	for (ll k = 0;k < i;k++)
  	    	  if (used[k] == 0 and s[i] >= s[k] and len[k] + 1 > len[i])
  	    	    {
  	    	    	len[i] = len[k] + 1;
  	    	    	pre[i] = k;
				  }
		  }
	ll maxpos = -1;
	for (ll i = 0;s[i];i++)
	  if (used[i] == 0)
	    {
	    	if (maxpos == -1)
	    	  maxpos = i;
	    	else if (len[i] > len[maxpos])
	    	  maxpos = i;
		}
	do
	  {
	  	v.push_back(maxpos);
	  	used[maxpos] = 1;
	  	maxpos = pre[maxpos];
	  }while (maxpos != -1);
	sort(v.begin(),v.end());
	cout << "+ " << v.size() << endl;
	for (auto it : v)
	  cout << s[it];cout << endl;
	return v;
  }
int main()
  {
  	ll len;
  	cin >> len >> s;
  	vector<vector<ll>> v;
  	for (ll i = 0;s[i];i++)
  	  {
  	  	ll pos = -1;
  	  	for (ll k = 0;k < v.size();k++)
  	  	  if (s[v[k].back()] <= s[i])
  	  	    {
  	  	    	if (pos == -1)
  	  	    	  pos = k;
  	  	    	else if (s[v[k].back()] > v[pos].back())
  	  	    	  pos = k;
				}
		if (pos == -1)
		  v.push_back(vector<ll>()),
		  v.back().push_back(i);
		else
		  v[pos].push_back(i);
	/*	for (auto it : v)
		  {
		  	cout << "+ " << endl;
		  	for (auto val : it)
		  	  cout << val << " ";
		  	cout << endl;
		  }*/
		}
	if (v.size() == 1)
	  {
	  	cout << "YES\n";
	  	for (ll i = 0;s[i];i++)
	  	  cout << 0;
	  }
	else if (v.size() == 2)
	  {
	  	cout << "YES\n";
	  	for (ll i = 0;s[i];i++)
	  	  s[i] = '0';
	  	for (auto it : v[0])
	  	  s[it] = '1';
	  	cout << s;
	  }
	else
	  cout << "NO\n";
    return 0;
}

#include <bits/stdc++.h>
#define double long double
#define endl '\n'
#define ll long long
using namespace std;

ll n;
string s, ans;
bool f = true;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    cin >> s;
    ans = s;
    for (int i = 0; i < n - 2; i ++)
        if ((s[i] > s[i + 1]) && (s[i + 1] > s[i + 2]))
        {
            cout << "NO";
            return 0;
        }
    for (int i = 0; i < n - 1; i ++)
        if (s[i] <= s[i + 1])
            ans[i] = '0';
        else
        {
            ans[i] = '1';
            ans[i + 1] = '0';
        }
    ans[n - 1] = '0';
    cout << "YES" << endl;
    cout << ans;
    return 0;
}

/*
 * @Author: cy
 * @Date: 2020-02-25 15:40:28
 * @LastEditors: cy
 * @LastEditTime: 2020-02-25 16:28:35
 * @FilePath: \dp\cf_dp\3.cpp
 * @Problem:  String Coloring (easy version) *1800
 * @Link:  https://codeforces.com/problemset/problem/1296/E1
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int num=1e5+3;
char s[110];
int vs[110];
int main()
{
    int len;
    scanf("%d%s",&len,s);
    int f=0;
    for(int i=0;i<len;i++)
    {
        for(int j=i+1;j<len;j++)
        {
            if(s[j]>s[i]) continue;
            for(int k=j+1;k<len;k++)
            {
                if(s[k]<s[j]) f=1;
            }
        }
        if(f) break;
    }
    if(f) { printf("NO"); return 0;}
    for(int i=0;i<len;i++)
    {
        f=0;
        for(int j=i+1;j<len;j++)
        if(s[j]<s[i]) {f=1;break;}
        vs[i]=f;
    }
    printf("YES\n");
    for(int i=0;i<len;i++)
    printf("%d",vs[i]);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 1<<29;

int main(){
    int T = 1;
    //cin >> T;
    while (T--){
        int n;
        string s;
        vector<int> col;
        int max = 0;
        bool ans = true;
        cin >> n >> s;
        for (int i = 0; i<n; i++){
            if ((int) s[i] > max){
                max = (int) s[i];
            } else {
                col.push_back(i);
            }
        }
        if (col.size() == 0){
            cout << "YES" << endl;
            string z(n,'0');
            cout << z << endl;
            continue;
        }
        max = (int) s[col[0]];
        for (int i = 1; i<col.size(); i++){
            if (max > (int) s[col[i]]){
                ans = false;
                break;
            }
            max = (int) s[col[i]];
        }
        if (ans){
            cout << "YES" << endl;
            string z(n,'0');
            for (int i = 0; i<col.size(); i++) z[col[i]] = '1';
            cout << z << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string str;
	cin >> str;
	int* color = new int[n];
	int* final = new int[n];
	final[0] = 0;
	color[0] = 0;
	for (int i =1;i<n;i++)
	{
		int j=0;
		bool one = false;
		bool zero = false;
		int change = 0;
		for (int k=i-1; k>=0;k--)
		{
			j = k;
			if (str[k]<=str[i])
			{
				change = 1;
				break;
			}
			if (color[k]==1) one = true;
			else zero = true;
		}
		if (one && zero)
		{
			cout << "NO" << endl;
			return 0;
		}
		if (change)
		{
			if (zero) color[i]=1;
			else color[i]=0;
		}
		else color[i] = color[i-1];
		final[i] = color[i];
		for (int k=i-1;k>j;k--)
		{
			char tmp = str[k+1];
			str[k+1] = str[k];
			str[k] = tmp;
			int t = color[k+1];
			color[k+1] = color[k];
			color[k] = t;
		}

	}
	cout << "YES" << endl;
	for (int i =0;i<n;i++) cout<<final[i];
	cout << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define it register int
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
const int maxn=2e5+10;
int n,a[500];
char s[500];
int main(){
    mem(a,-1);
    scanf("%d",&n);
    scanf("%s",s);
    a[0]=0;
    int ff=1;
    for(it i=1;i<n;i++){
        for (int j=0;j<i; j++) {
			if (s[j]>s[i]) {
				a[i]= 1;
			}
		}
		for (int k=i+1;k<n; k++) {
			if (s[i]>s[k] && a[i]==1) {
				ff = 0;
				break;
			}
		}
		if(!ff){
			break;
		}

    }
    if(ff){
        printf("YES\n");
        for(it i=0;i<n;i++){
            printf(i==n-1?"%d\n":"%d",a[i]);
        }
    }
    else{
            printf("No\n");
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>

#pragma comment(linker, "/STACK:36777216")

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout.precision(20); cout.setf(ios::fixed);
	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<int>clr(n, -1);
	vector<int>p(n);
	iota(all(p), 0);

	for (int i = 1; i < n; i++) {
		if (s[p[i]] >= s[p[i - 1]]) continue;
		int j = i;
		while (j > 0 && s[p[j]] < s[p[j - 1]]) {
			if (clr[p[j - 1]] != -1) {
				if (clr[p[j]] == clr[p[j - 1]]) {
					cout << "NO\n";
					return 0;
				}

				if (clr[p[j]] == -1) clr[p[j]] = clr[p[j - 1]] ^ 1;
			}
			else {
				if (clr[p[j]] == -1) {
					clr[p[j]] = 0;
				}

				clr[p[j - 1]] = clr[p[j]] ^ 1;
			}

			swap(s[p[j]], s[p[j - 1]]);
			swap(p[j], p[j - 1]);
			j--;
		}
	}

	cout << "YES\n";
	vector<int>ans(n);
	for (int i = 0; i < n; i++) {
		if (clr[i] == -1) clr[i] = 0;
		//cout << clr[i];
		ans[p[i]] = clr[i];
	}

	//cout << '\n';
	for (auto& x : ans) cout << x;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define xx first
#define yy second
const int mod = 1000000007;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N, seg[200005 * 4], ans[200005];
string S;
pii arr[200005];
void update(int n, int k) {
	while (n != 0) {
		seg[n] |= k;
		n /= 2;
	}
}
int get(int s, int e) {
	int v = 1;
	while (s <= e) {
		if (s % 2 == 1) {
			v |= seg[s++];
		}
		if (e % 2 == 0) {
			v |= seg[e--];
		}
		s /= 2; e /= 2;
	}
	int ret = 0;
	v /= 2;
	while (v != 0) {
		if (v % 2 == 1) {
			ret++;
		}
		v /= 2;
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> S;
	for (int i = 0; i < S.length(); i++) {
		arr[i] = { S[i] - 'a',i };
	}
	sort(arr, arr + N);
	reverse(arr, arr + N);
	int s = 1;
	while (s <= N) s *= 2;
	s--;
	int maxV = 0;
	for (int i = 0; i < N; i++) {
		int v = get(s + 1, s + arr[i].yy + 1);
		ans[arr[i].yy] = v + 1;
		maxV = max(maxV, v + 1);
		update(s + arr[i].yy + 1, (1 << v + 1));
	}
	if (maxV >= 3)cout << "NO\n";
	else {
		cout << maxV << "\n";
		for (int i = 0; i < N; i++) {
			cout << ans[i] - 1<< " ";
		}
	}
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
    long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
    }
    long long gcd(long long a, long long b) {
        if (a==0) return b;
        if (b==0) return a;
        if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
    }
      int prime(int p) { // 1 - простое
        for (int i=2;i*i<=p;i++) {
            if (p%i==0 && i<p) return i;
        }
        return 1;
    }

     int inv(int a, int mod) {
        return powmod(a,mod-2,mod);
    }
  int random_modul() {

    uniform_int_distribution <int> u1(1e10, 1e11);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

    void solve () {

         /* --------- */
         int a; cin>>a;
    string s;
    cin>>s;
    int m[a];
    for (int i=0;i<a;i++) m[i]=s[i]-'a';
    int dp[a];
    int cur=0;
    vector<vector<int>> last(26);
    for (int i=0;i<a;i++) {
        int q=m[i]; int check=0;
        for (int j=q;j>=0;j--) if (last[j].size()!=0) {dp[i]=dp[last[j][last[j].size()-1]]; last[j].pop_back(); check=1; break; }
        if (check==0) {cur++; dp[i]=cur; }
        last[m[i]].push_back(i);
    }
   if (cur==2) cout<<"YES\n"; else cout<<"NO";
   if (cur==2) {
       for (int i=0;i<a;i++) cout<<dp[i]-1<<"";
   }
            return;
    }

    signed main() {
       ios_base::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);

       //  cout<<fixed<<setprecision(10);

          int tututu;
          tututu=1;

    //  cin>>tututu; // если нет запросов, то закоментить

          for (int qwerty=0;qwerty<tututu;qwerty++) solve();

        return 0;
    }

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define All(x) x.begin() , x.end()
#define mem(aa,x) memset(aa,x,sizeof aa)
#define pb push_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
const int maxn=205;

vi v[maxn];
int ans[maxn];
bool visit[maxn];

bool dfs(int now,bool color){
	//cout<<"test"<<now<<" "<<color<<"\n";

	if(ans[now]==!color) return 0;
	if(visit[now]) return 1;

	ans[now]=color;
	visit[now]=1;

	for(auto i:v[now])
		if(!dfs(i,!color))
			return 0;

	return 1;
}

main(){IOS
	int n;
	string s;
	cin>>n>>s;
	rep(i,0,n-1)
		rep(j,i+1,n-1)
			if(s[i]>s[j]){
				v[i].pb(j);
				v[j].pb(i);
			}
	mem(ans,-1);
	mem(visit,0);

	rep(i,0,n-1){
		if(ans[i]==-1){
			if(!dfs(i,0)){
				puts("NO");
				return 0;
			}
		}
	}

	puts("YES");
	rep(i,0,n-1) cout<<ans[i];
	cout<<"\n";
}

#include <bits/stdc++.h>

using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<int> color(n,-1);

  string s;
  cin>>s;

  bool possible = true;

  for(int j=0;possible && j<n;j++){
    for(int i=1;i<n;i++){
      if(s[i]<s[i-1]){
        if(color[i]==-1){
          if(color[i-1]==-1){
            swap(s[i],s[i-1]);
            color[i] = 1;
            color[i-1] = 0;
          }
          else if(color[i-1]==1){
            swap(s[i],s[i-1]);
            color[i] = 1;
            color[i-1] = 0;
          }
          else{
            swap(s[i],s[i-1]);
            color[i] = 0;
            color[i-1] = 1;
          }
        }
        else if(color[i]==1){

          if(color[i-1]==-1){
            swap(s[i],s[i-1]);
            color[i] = 0;
            color[i-1] = 1;
          }
          else if(color[i-1]==1){
            // cout<<"1---->"<<s[i-1]<<" "<<s[i]<<endl;
            possible = false;
            break;
          }
          else{
            swap(s[i],s[i-1]);
            color[i] = 0;
            color[i-1] = 1;
          }

        }
        else{

          if(color[i-1]==-1){
            swap(s[i],s[i-1]);
            color[i] = 1;
            color[i-1] = 0;
          }
          else if(color[i-1]==0){
            // cout<<"0---->"<<s[i-1]<<" "<<s[i]<<endl;
            possible = false;
            break;
          }
          else{
            swap(s[i],s[i-1]);
            color[i] = 1;
            color[i-1] = 0;
          }

        }
      }
    }
  }
  if(possible){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}

int main() {
#ifdef LOCAL_EXEC
	freopen("grader.in", "r", stdin);
	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  // int t; cin >> t;
  // for (int tc = 1; tc <= t; tc++) {
  //   cout << "Case #" << tc << ": ";
    solve();
  // }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define si short int
#define ll long long
#define db double
#define ff first
#define s second

void solve(){
	int n;cin>>n;
	string s;cin>>s;
	string a;
	a.resize(n);
	for(int i=0;i<n;i++)a[i]='0';

	for(int i=1;i<n;i++){
		if(s[i]<s[i-1]){
			if(a[i-1]=='1'){cout<<"NO"<<endl;return;}
			a[i]='1';
		}
	}
	cout<<"YES"<<endl;
	cout<<a<<endl;
}

int main(){
	solve();
}

#include <bits/stdc++.h>
using namespace std;

#define M 1000000007
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
bool cmp(pii p1,pii p2){
    if(p1.first<p2.first){
        return true;
    }
    if(p1.first==p2.first&&p1.second<p2.second){
        return true;
    }
    return false;
}
ll n,q;
ll a_x[] = {1,-1,1,-1};
ll a_y[] = {-1,-1,1,1};
int main(){

  ll n;
  cin>>n;
  string s;
  cin>>s;
  int cur=-1,st=1;
  int in[n+1],color[n+1]={-1};
  for(int i=0;i<n;i++){
      in[i]=i;
  }
  vector<int>v[n+1];
  int k=0;
  for(int i=1;i<n;i++){
      int l=i,r=i;
      for(int j=i;j>=0;j--){
          if(s[in[j]]<s[in[j-1]]){
              r=j-1;
              swap(in[j],in[j-1]);
              v[k].pb(in[j-1]);
          }
          else {
              break;
          }
      }
      if(l!=r){
          if(r<=cur){
              st=0;
              break;
          }
          cur=r;
          v[k].pb(in[r]);
          k++;
      }
  }
  if(st==0){
      cout<<"NO";
      return 0;
  }

  cout<<"YES"<<endl;
  int co=0;
  for(int i=0;i<k;i++){
      for(int j=0;j<v[i].size()-1;j++){
          int in=v[i][j];
          if(color[in]!=-1){
              co=color[in];
          }else {
              color[in]=co;
          }
      }
      color[v[i][v[i].size()-1]]=!co;
  }

  for(int i=0;i<n;i++){
      if(color[i]==-1){
          color[i]=0;
      }
      cout<<color[i]<<" ";
  }
}

#include<bits/stdc++.h>

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
	int f = 0, fu = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-')fu = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		f = (f << 3) + (f << 1) + c - 48;
		c = getchar();
	}
	return f * fu;
}
const int N=105;
char str[N];
pii a[N];
int ans[N];
int n;
void out() {
	repi(i,1,n)printf("%d%c",a[i].fi,ce(i,n));
}
int main() {
	n=qr();
	ss(str+1);
	repi(i,1,n)a[i].fi=str[i]-'a',a[i].se=i;
	repi(i,1,n-1)repd(j,n,i+1) {
		if(a[j-1].fi>a[j].fi) {
			if(ans[a[j-1].se]==ans[a[j].se]) {
				if(!ans[a[j-1].se])ans[a[j-1].se]=true;
				else {
					puts("NO");
					return 0;
				}
			}
			swap(a[j-1],a[j]);
		}
	}
	repi(i,1,n-1)if(a[i].fi>a[i+1].fi) {
		puts("NO");
		return 0;
	}
	puts("YES");
	repi(i,1,n)printf("%d",ans[i]);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define x1 first
#define y1 second
#define frb(i,a,b) for(int (i)=(a);(i) <= (b); (i)+=(i)&-(i))
#define rfrb(i,a) for(int (i)=(a);(i) > 0;(i)-=(i)&-(i))
#define fr(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rep(i,c) for(auto (i) : (c))
#define mini(a,b) ((a) < (b)) ? (a) : (b)
#define maxi(a,b) ((a) > (b)) ? (a) : (b)
int n;
string a,b;
int ar[200005];
int as[300];
char maxs;
char maxs1;
int id;
int id1;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.setf(ios::fixed);cout.precision(0);
    cin>>n>>a;
    b = a;
    sort(b.begin(),b.end());
    int cont = 0;
    fr(i,1,n)if(!as[b[i]]){cont++;as[b[i]]=cont;}
    fr(i,1,n){
        if(i==1){if(a[i-1]!=b[i-1])ar[i] = 1;}
        else{
            if(as[a[i-1]]==as[a[i-2]] || as[a[i-1]] > as[a[i-2]])ar[i] = ar[i-1];
            else ar[i] = !ar[i-1];
        }
        if(ar[i]==1){
            if(maxs < a[i-1]){
                maxs = a[i-1];
                id = as[a[i-1]];
            }
        }
        else{
            if(maxs1 < a[i-1]){
                maxs1 = a[i-1];
                id1 = as[a[i-1]];
            }
        }
        if(as[a[i-1]]<as[a[i-2]]){
            if(ar[i-1]==1 && maxs1!='0' && id1 > as[a[i-1]]){cout<<"NO";return 0;}
            if(ar[i-1]==0 && maxs!='0' && id > as[a[i-1]]){cout<<"NO";return 0;}
        }
    }
    cout<<"YES\n";
    fr(i,1,n)cout<<ar[i];
    return 0;
}

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug cout<<"here"<<endl;
#define ll long long int
#define mp make_pair
#define pb push_back
#define endl '\n'
const ll MOD=1e9+7;
#define MAX 200005
#define infi 1e12
#define intial 0
#define waiting 1
#define visited 2
#define PII pair<ll,ll>
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
using namespace std;
int main()
{
	#ifndef LOCAL
	fast;
	#endif
	int n;
	cin>>n;
	std::vector<pair<char,int> >v(n);
	for(int i=0;i<n;i++){
		char ch;
		cin>>ch;
		v[i]=mp(ch,i);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(v[i].first>=v[j].first)
				swap(v[i],v[j]);
		}
	}
	std::vector<int>vec(n);
	for(int i=0;i<n;i++){
		vec[i]=v[i].second;
		// cout<<vec[i]<<" ";
	}
	int color[n];
	for(int i=0;i<n;i++)
		color[i]=-1;
	// cout<<endl;

	for(int i=0;i<n;i++){
		// find index of i in given vec
		int indx;
		for(int j=i;j<n;j++){
			if(vec[j]==i){
				indx=j;
				break;
			}
		}

		// needs to move from indx to indx i;
		int zero=0;
		for(int j=indx-1;j>=i;j--){
			if(color[vec[j]]==0)
				zero++;
		}
		int req;
		if(color[i]!=-1)
			req=(color[i]+1)%2;
		else if(zero!=0){
			color[i]=1;
			req=0;
		}
		else{
			color[i]=0;
			req=1;
		}
		for(int j=indx-1;j>=i;j--){
			if(color[vec[j]]==-1||color[vec[j]]==req)
				color[vec[j]]=req;
			else{
				cout<<"NO"<<endl;
				return 0;
			}
		}
		for(int j=indx;j>i;j--)
			swap(vec[j],vec[j-1]);

		// cout<<i<<": ";
		// for(int j=0;j<n;j++)
		// 	cout<<vec[j]<<" ";
		// cout<<endl;
		// for(int j=0;j<n;j++)
		// 	cout<<color[vec[j]]<<" ";
		// cout<<endl;
	}
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++)
		cout<<color[i];
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,a[200003],maxx[200],maxxx=0,ans[200003],col;
char c;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		a[i]=c-'a'+1,maxxx=0;
		for(int j=a[i]+1;j<=26;j++)
			maxxx=max(maxxx,maxx[j]);
		ans[i]=maxxx+1,col=max(col,ans[i]);
		maxx[a[i]]=max(maxx[a[i]],maxxx+1);
	}
	cout<<col<<endl;
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define int long long
#define mk make_pair
#define mod 1000000007
#define INF 100000000000000000
#define nope() cout<<"NO"<<endl;return 0;
int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}

int gcd(int a,int b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}

int max(int a,int b){
	if(a>b){
		return a;
	}
	return b;
}

int32_t main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int arr[n]={0};
    for(int i=0;i<n;i++){
        int temp=0;
        char c=s[i];
        int ind;
        for(int j=i+1;j<n;j++){
            if(s[j]<c && temp==0){
                temp++;
                c=s[j];
                arr[j]=1-arr[i];
            }
            else if(s[j]<c && temp==1){
                cout<<"NO"<<endl;
                return 0;
            }
            else{
                arr[j]=arr[i];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++){
        cout<<arr[i]<<"";
    }
    cout<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define fp(i,a,b) for(register int i=a;i<=b;i++)
#define fb(i,a,b) for(register int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define scf(a,b) scanf("%d%d",&a,&b)
int n,maxx,dp[300],co[300];char s[300];
int main(){
	sc(n);cin>>(s+1);
	fp(i,1,n){
		dp[i]=1;
		fp(j,1,i-1)
		if(s[j]>s[i]){
			dp[i]=max(dp[i],dp[j]+1);
			maxx=max(maxx,dp[i]);
		}
	}
	if(maxx>2) puts("NO");
	else{
		co[1]=0;
		int len=strlen(s+1);
		fp(i,2,len){
			if(s[i]<s[i-1]) co[i]=abs(1-co[i-1]);
			else co[i]=co[i-1];
		}
		puts("YES");
		fp(i,1,n) printf("%d",co[i]);
		puts("");
	}
	return 0;
}