Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:  Each digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones).  Digits are written one by one in order corresponding to number and separated by single '0' character. Though Polycarp learnt how to encode the numbers, he has no idea how to decode them back. Help him calculate the decoded number.

The first line contains one integer number n (1 ≤ n ≤ 89) — length of the string s. The second line contains string s — sequence of '0' and '1' characters, number in its encoded format. It is guaranteed that the number corresponding to the string is positive and doesn't exceed 109. The string always starts with '1'.

#include <bits/stdc++.h>
#define ll long long
#define NUM
#define ACC    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
string s;
int n;

int main()
{
    ACC
    int d=0,c=0;
    cin >> n; cin >> s;
    if(s == "0")return cout << 0,0;
    for(int i=0; i<n; i++)
    {
        if(s[i] == '1')
        {
            c=0;
            int j=i;
            while(j<n&&s[j] == '1')
            {
                c++;
                j++;
            }
            cout << c;
            i=j-1;
        }

        else
        {
            int j=i;
            int c=0;
            while(s[j] == '0')
            {
                j++;
                c++;
            }
            if(j == n)
                c++;
            for(int k=0;k<c-1;k++)cout << 0;
            i=j-1;

        }
    }

    return 0;
}

/*
#include <bits/stdc++.h>
#define ll long long
#define NUM
#define ACC    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int n;

char s[100][100];
int col[20];
int row[20];
int dot,x;
int main()
{
    ACC

    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            cin >> s[i][j];

    for(int i=0; i<=10-5; i++)
    {
        for(int j=0; j<=10-5; j++)
        {
            if(s[i][j] == '.' || s[i][j] == 'X')
            {
                dot=0;
                x=0;
                for(int k=j; k<j+5; k++)
                {
                    if(s[i][k] == '.')dot++;
                    else if(s[i][k] == 'X')x++;
                }
                if(dot<=1 && x>=3 && x+dot == 5)return cout << "YES",0;
                dot=0;
                x=0;
                for(int k=j; k<j+5; k++)
                {
                    if(s[k][j] == '.')dot++;
                    else if(s[i][k] == 'X')x++;

                }
                if(dot<=1 && x>=3 && x+dot == 5)return cout << "YES",0;

            }
        }
    }
    cout << "NO";

}
*/

/*
#include <bits/stdc++.h>
#define ll long long
#define NUM
#define ACC    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int n;

char s[100][100];
int col[20];
int row[20];
ll a[10004];
ll dot,x,c;
set<int>st;
set<int>::iterator it;

int main()
{
    ACC
    ll n,k;
    cin >> n >> k;
    st.insert(k);
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }

    sort(a,a+n);
    for(int i=0; i<n; i++)
    {
        ll d=a[i]/2;

        it=st.end();
        it--;
        int k=*it;
        if(d>k)c++;
        else
        {
            st.insert(a[i]);
        }

    }

    cout << c;

}
*/

#include<bits/stdc++.h>
using namespace std;
int len,cnt;
bool f=true;
string s;
int main()
{
	cin>>len;
	cin>>s;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='1') cnt++;
		else cout<<cnt,cnt=0;
	}
	cout<<cnt;
	return 0;
}

#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)
#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
using namespace std;
int32_t main()
{
    //freopen("in.txt", "r", stdin);
    int n,cnt1=0,cnt0=0;
    sci(n);
    string str;
    cin>>str;
    for(int i=0; i<n; i++)
    {
        if(str[i]=='1')
        {
            //cout<<"ggg"<<endl;
            if(cnt0>1)
            {
                //cout<<"ppp"<<endl;
                for(int j=1; j<=cnt0-1; j++)
                {
                    cout<<"0";

                }
             cnt0=0;
            }
            cnt1++;
            cnt0=0;
        }
        else if(cnt0==0 && str[i]=='0')
        {
            cout<<cnt1;
            cnt1=0;
            cnt0++;
        }
        else
        {
            cnt0++;
        }

    }
    //cout<<cnt1<<" "<<cnt0<<endl;
    if(cnt1>0)
    {
        cout<<cnt1;
    }
    else
    {
        //cout<<"sssss"<<endl;
        for(int i=n-1; i>=0; i--)
        {
            if(str[i]=='0')
            {
                cout<<str[i];
            }
            else
            {
                break;
            }
        }
    }
    cout<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

#define inf                  1e9   // this is double value
#define ms(a,b)              memset(a,b,sizeof a)
#define CLR(a)               memset(a,0,sizeof a)
#define input_file           freopen("in.txt","r",stdin)
#define output_file          freopen("out.txt","w",stdout)
#define N                    100000008
#define LL                   long long
#define nl                   printf("\n")
#define spc                  printf(" ")
#define isValid(x,y,dx,dy)   ((0<=dx&&dx<x) && (0<=dy&&dy<y))
#define Abs(a,b)             a>b ? a-b : b-a // if a>b is true return a-b eles b-a

int main()
{
	int n,i,one,zero,x,arr[100005],flag;
	char str[100005];
	while(cin>>n>>str)
	{
		one=zero=x=flag=0;
		for(i=0; i<=n; i++)
		{
			if(str[i]=='1')
			{
				flag=0;
				one++;
				if(zero>1)
				{
					zero--;
					while(zero--)
						arr[x++]=0;
				}
				zero=0;
			}
			else if(str[i]=='0')
			{
				zero++;
				if(flag==0)
					arr[x++]=one;
				one=0;
				flag=1;
			}
			else
			{
				if(one>0)
					arr[x++]=one;
				else
				{
					while(zero--)
						arr[x++]=0;
				}
			}
		}
		for(i=0; i<x; i++)
			cout<<arr[i];
		nl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
ll power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	string ans="";
	for(int i=0;i<n;i++){
		cnt=0;
		while(s[i]!='0'&&i<n){
			i++;
			cnt++;
		}
		char c='0';
		c+=cnt;
		ans=ans+c;
		if(s[i]=='0'&&i<n){
			i++;
			while(s[i]=='0'&&i<n){
				ans=ans+"0";
				i++;
			}
			i--;
		}
	}
	if(s[n-1]=='0')
		ans=ans+"0";
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int T=1;
	//cin>>T;
	while(T--)
		solve();
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <time.h>
#include <random>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <unordered_set>
#include <unordered_map>
#define rt return
#define rt0 return 0
#define rt1 return 1
#define mp make_pair
#define endl "\n"
#define cen cout << "\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const ll inf = 1000000007;
const int sz = 100100;
const db eps = 1e-9;

ll n, mn = 1;
string s;
ll rs;
int main(){
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	//	ios_base::sync_with_stdio(false);
	//	cin.tie(NULL);
	cin >> n >> s;
	reverse(s.begin(), s.end());
	int cnt = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '1') {
			++cnt;
		}
		else {
			rs += mn * cnt;
			mn *= 10;
			cnt = 0;
		}
	}
	rs += mn * cnt;
	mn *= 10;
	cnt = 0;

	cout << rs;

	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#pragma GCC optimize(2)
using namespace std;
int n,cnt; string st;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>st;
	for(int i=0;i<=n;i++)
		if(st[i]=='1') cnt++;
		else{
			cout<<cnt;
			cnt=0;
		}
}

#include<cstdio>
#include<iostream>
using namespace std;
int n;
int sum=0;
char a[1000010];
int main()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
     for (int i=1;i<=n;i++)
     {
         if (a[i]=='1')
        {
            sum++;
         }
         else
         {
             cout<<sum;
             sum=0;
         }
     }
     cout<<sum;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	int temp=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if(s[i]=='1'&&s[i-1]=='1')
			temp++;
		else
			if(s[i]=='0')
			{
				if(s[i-1]=='0')
					ans*=10;
				else
				{
					ans*=10;
					ans+=temp;
					temp=1;
				}
			}
		if(s[i]=='1'&&i==n-1)
		{
			ans*=10;
			ans+=temp;
		}
		if(s[i]=='0'&&i==n-1)
			ans*=10;
	}
	cout<<ans;

	return 0;
//hi`
}

#include<iostream>
using namespace std;
int main(){
    char a;
    bool flag=1;
    int n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a!='0'){
            sum++;
            flag=1;
        }
        else if(flag==1&&a=='0'){
            cout<<sum;
            sum=0;
            flag=0;
        }
        else if(a=='0'&&flag==0) cout<<"0";
    }
    cout<<sum;
    return 0;
}

#include<iostream>
using namespace std;
string a;
int n,c[93],s,h;
int main(){
cin>>n>>a;
for(int i=0;i<n;i++){
if(a[i]=='1') s++;
else if(a[i-1]=='1') c[++h]=s,s=0;
else c[++h]=0;}
c[++h]=s;
for(int i=1;i<=h;i++)
cout<<c[i];}

#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a;
	string b;
	cin >> a;
	cin >> b;
	int num = 0;
	for (int i = 0; i < b.size();i++) {
		if (b[i] == '1') {
			num++;
			if (i == b.size() - 1) {
				cout << num;
			}
		}
		else {
			cout << num;
			num = 0;
			if (i == b.size() - 1) {
				cout << "0";
			}
		}

	}

	return 0;
}

#include<iostream>
#include<string>
using namespace std;
string instr;
int outnum,strsize,k;
int main()
{

	cin >> strsize >> instr;
	if (instr[strsize-1] == '0')
	{
		instr.push_back( '0');
		strsize++;
	}
	for (int i = 0; i < strsize; i++)
	{
		k = 0;
		while (instr[i]=='1')
		{
			k++;
			i++;

		}
		cout << k;
	}
	cout << "\n";

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j=1,ans=0;
    string s;
    cin>>n;
    cin>>s;
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1'){
            ans++;
            c=0;
        }

        else if(s[i]=='0')
        {
            cout<<ans;
            ans=0;
        }

    }
   // if(ans>0)
        cout<<ans<<endl;

}

 #include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;
ll t,n,c11,sum,m,mn,k,mx,avg;
map<ll,ll>mp ;
int cum[100002];
bool isPrime(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
int main(void)
{
    SpeeD;
    int c=0,c1=0;
 cin>>n;
 string s;
 string ans="";
  cin>>s;

  for (int i =0 ; i  <s.length();i++)
  {

  if (s[i]=='1')

  {
     c++;
    c1=0;
  }

  else
  {
      c1++;
      c1=0;
      cout<<c;
      c=0;
      if (c1>1)
      cout<<0;
  }
       if (i==s.length()-1){
     if(s[s.length()-1]=='1')
       cout<<c;
       else   cout<<0;
       }
  }

}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
char str[95];
int main(){
	int n;
	LL ans;
	while(~scanf("%d",&n)){
		ans=0;
		scanf("%s",str);
		int j=n-1;
		int sum=0;
		while(str[j]!='1'&&j>=0){
			j--;
			sum++;
		}
		for(int i=0;i<=j;){
			if(str[i]=='1'){
				int cnt=0;
				while(str[i]=='1'&&i<=j){
					cnt++;
					i++;
				}
				ans *= 10;
				ans += cnt;
			}

			else if(str[i]=='0'){
				int cnt=0;
				while(str[i]=='0'&&i<=j){
					cnt++;
					i++;
				}
				if(cnt>1){
					for(int j=0;j<cnt-1;j++){
						ans *= 10;
					}
				}
			}
		}
		for(int i=0;i<sum;i++){
			ans *= 10;
		}
		printf("%I64d\n",ans);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
char a[91];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",a+1);
	int l=strlen(a+1);
	int sum1=0;
	for(int i=1;i<=l;i++)
	{
		if(a[i]=='1')
		sum1++;
		else
		{
			printf("%d",sum1);
			sum1=0;
		}
	}
	printf("%d\n",sum1);
	return 0;
}

 #include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool isPrime(long long n)
{
    if (n <= 1)
        return false;
    for (long long i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
long long SieveOfEratosthenes(long long n, long long a)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (long long p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (long long i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (long long p=2; p<=n; p++)
       if (prime[p])
       {
           if(a%p==0)
           {
               return (a-p);
           }
       }
}
long long nCr(int n, int r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}
int main()
{
    IOS;
    long long a,b,c,d,e,g,h,n,t,f,k,l,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr[100001],arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1;
    long long MOD=1e9+7;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3;
    char ch,ch1;
    vector<long long>v;
    vector<long long>v1;
    vector<string>vs;
    vector<string>vs1;
    map<char,long long>mp;
    map<char,int>mp1;
    set<long long>s;
    set<long long>s1;
    list<long long>li;
    list<long long>::iterator it;
    queue<long long> q;
    vector< pair<long long,long long> >v3;
    //map<string,string>::iterator it;
   // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>n;
    cin>>str;
    co=1;
    co1=0;
    if(str.size()==1)
    {
        cout<<1<<endl;
        return 0;
    }
    for(int i=0; i<n-1; i++)
    {
        if(str[i]==str[i+1] && str[i]=='1')
        {
            co++;
            continue;
        }
        else
        {
            if(str[i]=='1')
            v.push_back(co);
            co=1;
        }
        if(str[i]==str[i+1] && str[i]=='0')
        {
            co1++;
        }
        else
        {
            for(int j=1; j<=co1; j++)
                v.push_back(0);
            co1=0;
        }
    }
    if(co>1)
        v.push_back(co);
    for(int j=1; j<=co1; j++)
        v.push_back(0);
    if(str[str.size()-1]=='1' && str[str.size()-2]=='0')
        v.push_back(1);
    if(str[str.size()-1]=='0')
        v.push_back(0);
    for(int i=0; i<v.size(); i++)
        cout<<v[i];
    cout<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int maxn = 100;
char s[maxn];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> s[i];
    for(int i = 0; i < n; i++) s[i] -= '0';
    int c = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 0)
        {
            if(c == 0) cout << 0;
            else
            {
                cout << c;
                c = 0;
            }
        }
        else if(s[i] == 1) c++;
    }
    if(c != 0)
    {
        cout << c;
        c = 0;
    }
    else cout << '0';
}

#ifdef __GNUC__
#pragma GCC target("sse4,avx")
#endif
#include <immintrin.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <cstdint>
#include <numeric>

void run(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    std::string s;
    in >> s;
    s.push_back('0');
    int res = 0;
    int cur = 0;
    for (size_t i = 0; i < s.length(); i++) {
        if (s[i] == '1') {
            cur++;
        } else {
            res = 10 * res + cur;
            cur = 0;
        }
    }
    out << res << std::endl;
}

int main() {
  std::cin.sync_with_stdio(false);
  std::cin.tie(nullptr);
  run(std::cin, std::cout);
  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <crtdbg.h>
#include <ctype.h>
#include <math.h>

#define min(a,b) (((a)<(b)) ? (a) : (b))
#define max(a,b) (((a)>(b)) ? (a) : (b))
#define MOD 1000000007

int Compare(const void * x1, const void * x2)
{
	return (*(int*)x1 - *(int*)x2);
}

int main(void)
{
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
	int n, l, r;
	char s[150];
	scanf("%d\n", &n);
	gets(s);
	l = 0;
	while (l < n)
	{
		while (l < n && s[l] == '0')
		{
			printf("0");
			l++;
		}
		r = l;
		while (r < n && s[r] == '1')
		{
			r++;
		}
		printf("%d", r - l);
		l = r + 1;
	}
	if (n >= 2 && s[n - 1] == '0' && s[n - 2] == '1')
	{
		printf("0");
	}
	printf("\n");
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}

#include<iostream>
using namespace std;
#include<stdlib.h>
int main()
{
	int n;
	char s[1000];
	cin >> n;
	for (int i = 1,j=0,k=0; i <= n+1; i++)
	{
		char a;
		if (i != n + 1)
			cin >> a;
		else if (i == n + 1)
			a = '0';
		if (a == '1')
		{
			j++;
		}
		else if (a == '0')
		{
			s[k] = j + 48;
			k++;
			j = 0;
			if (i == n + 1)
				s[k] = '\0';
		}

	}
	int m = atoi(s);
		cout << m << endl;
	return 0;
}

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

int main (){

int limite, cifra = 0;
string nueva;
string secuencia;

cin >> limite;
cin >> secuencia;

for (int i = 0; i<= limite; i++){
    char num = secuencia[i];
    int pos = secuencia.find("00");

    if (num == '1'){
        cifra++;
    }
    else if (num != '1'){
        if (cifra == 1){
            nueva.push_back('1');
        }
        else if (cifra == 2){
            nueva.push_back('2');
        }
        else if (cifra == 3){
            nueva.push_back('3');
        }
        else if (cifra == 4){
            nueva.push_back('4');
        }
        else if (cifra == 5){
            nueva.push_back('5');
        }
        else if (cifra == 6){
            nueva.push_back('6');
        }
        else if (cifra == 7){
            nueva.push_back('7');
        }
        else if (cifra == 8){
            nueva.push_back('8');
        }
        else if (cifra == 9){
            nueva.push_back('9');
        }
        else {
        nueva.push_back('0');
        }
        cifra = 0;
    }
}

cout << nueva;

return 0;
}

	#include<bits/stdc++.h>
	using namespace std;
	const int MAX = 1005;

	int dp[MAX][MAX];

const int inf = 2e9;

	inline void speed(){
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);cout.tie(NULL);
	}

	void sol(){
	    int n;
	    cin>>n;
	    string s = "";
	    long long num = 0;
	  	cin>>s;
	  	long long  c=0;

	  	for(int i=0;i<s.length();i++){

	  		if(s[i] == '1'){
	  			c++;
	  		}else{
	  			cout<<c;
	  			c=0;
	  		}
	  	}

	  	cout<<c;

}

	int main() {

		speed();
		sol();
		return 0;
	}

#include <iostream>

using namespace std;

int n;
int s[110];
int ans[1000];
int a;
int main() {

	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		scanf("%1d",&s[i]);
	}
	int now = 0;
	while (now < n) {
		if (s[now] == 1) {
			int cnt = 0;
			while (s[now] == 1 && now < n) {
				cnt++;
				now++;
			}
			ans[a++] = cnt;
		}
		else {
			int cnt = 0;
			while (s[now] == 0 && now <n) {
				cnt++;
				now++;
			}
			while (cnt - 1) {
				ans[a++] = 0;
				cnt--;
			}
			if (now == n && cnt == 1) ans[a++] = 0;
		}
	}
	for (int i = 0; i < a; i++) cout << ans[i];
}

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

const int N = 110;

char str[N];
int n,sum;

int main()
{
    scanf("%d\n",&n);
    scanf("%s",str+1);
    for(int i=1;i<=strlen(str+1);i++) {
        if(str[i] == '1')
            sum++;
        else {
            printf("%d",sum);
            sum = 0;
        }
    }
    printf("%d\n",sum);
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define pi 3.141592653589793
#define pb push_back
#define forto(l,a,b) for(long long l = a; l <= b; ++l)
#define downto(l,a,b) for(long long l = a; l >= b; --l)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    sync;
    string s;
    long ans = 0, now = 0, r, n;
    cin >> n;
    cin >> s;
    r = n-1;
    forto(f, 0, r){
        if (s [f] == '1'){
            ++ now;
        }
        else {
            ans = ans*10 +now;
            now = 0;
        }
    }
    ans = ans*10 +now;
    cout << ans;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    char a[n];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]=='1')
        {
            sum++;
        }
        else
        {
            if(sum==0)
            {
                cout<<0;
            }
            else
            {
                cout<<sum;
                sum=0;
            }
        }
    }
    cout<<sum;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define rep(i,a,n) for(long long i=a;i<=n;i++)
typedef long long ll;
typedef long double ld;

#define NDEBUG
#ifdef NDEBUG
#define debug(...)
#else
#include"debug.cpp"
#endif

const int N=2e5+5;
long long test, n, m, k,x ,y ,q,z,d,ans ,b[N],a[N];

void solve(){
	cin >> n;
	string s;cin >> s;
	int cnt=0;
	rep(i,0,n-1){
		if(s[i]=='0' && s[i-1]=='0') cout<<0;
		else if(s[i]=='1') cnt++;
		else if(s[i]=='0') cout<<cnt,cnt=0;
	}
	if(cnt>0) cout<<cnt;
	if(s[n-1]=='0') cout<<0;
}

int main(){ //freopen("input.txt","r",stdin);

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//cin >> test;
	//while(test--)
	solve();

}

#include<bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
main()
{
	int n;
	cin>>n;
	string str,ans;
	cin>>str;
	bool flag=0;
	int cnt=0;
	fl(i,0,n)
	{
		if(str[i]=='1')
		{
			flag=0;
			cnt++;
		}
		else
		{
			if(flag)
			{
				ans.pb(0+48);
			}
			else
			{
				ans.pb(cnt+48);
			}
			cnt=0;
			flag=1;
		}
	}
	if(cnt>0)
	ans.pb(cnt+48);
	if(n>1)
	if(str[n-1]=='0')
	ans.pb(0+48);
	cout<<ans;
}

#include<cstdio>
#include<string>
#include<cstring>
#include<string.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#define inf_int 0x3f3f3f3f
#define inf_ll 0x3f3f3f3f3f3f3f3f
#define P(x,y)  make_pair(x,y)
#define lowbit(i1) (i1)&(-i1)
using namespace std;

int main()
{
	int n;
	while (scanf_s("%d", &n) != EOF)
	{
		vector<int> v;
		int cnt = 0;
		for (int i = 1; i <= n; i++)
		{
			char x;
			cin >> x;
			if (i == n&&x=='1')
			{
				cnt++;
				v.emplace_back(cnt);
				break;
			}
			if (x == '0')
			{
				v.emplace_back(cnt);
				cnt = 0;
				if (i == n)
					v.emplace_back(0);
			}
			else cnt++;
		}
		long long ans = 0;
		for(int i=0;i<v.size();i++)
		{
			ans *= 10;
			ans += v[i];
		}
		printf("%lld\n", ans);
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
const int NR = 89 + 1 + 10;
using namespace std;
int n;
char s[NR];
int main()
{
	cin >> n;
	cin >> s;
	int num = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '1')
			num++;
		if (s[i] == '0')
		{
			cout << num;
			num = 0;
		}
	}
	cout << num;
	cout << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100];
int main()
{
    int n;
    int num[10000];
    while(~scanf("%d",&n))
    {
        scanf("%s",s);
        int i,j;
        int cnt=0;
        memset(num,0,sizeof(num));
        for(i=0;i<n;i++)
        {
            if(s[i]=='0'&&s[i-1]=='1')
                continue;
            if(s[i]=='0')
                num[cnt++]=0;

            if(s[i]=='1')
                num[cnt]++;
            if(s[i]=='1'&&s[i+1]!='1')
                cnt++;
        }
        cnt--;
        if(s[n-1]=='0')
            cnt++;
        for(j=0;j<=cnt;j++)
            printf("%d",num[j]);
        printf("\n");
    }
    return 0;
}

#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,t=0;
	char a[95];
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
	{
		int k=0;
		while(a[i]=='1')
		{
			k++;
			i++;
		}
//		if(k)
			cout<<k;
	}
	if(a[n-1]=='0')
		cout<<0;
	cout<<endl;
	return 0;
}

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

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

	int n ;
	vector<int>v;
	int d=0;
	cin>>n;
	string s;
	cin>>s;
    bool p=false;
    int c=0;

    for(int i=0;i<n;i++)
    { if (s[i]=='0') { if (c!=0) cout<<c;
                       if (p==true) {cout<<0;}
                       p=true;
                       c=0;}
      else {c++; p=false;}
    }

    if (c!=0) cout<<c;
   if (s[n-1]=='0') cout<<0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    int n;
    string str;
    cin>>n>>str;
    int sum = 0;
    int flag = 0;
    for(int i = 0;i < n;i++){
        if(str[i] == '1') sum++,flag = 0;
        if(str[i] == '0'&&flag == 0) {cout<<sum;sum = 0;flag = 1;continue;}
        if(str[i] == '0'&&flag == 1) cout<<"0";
    }
    cout<<sum<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,i,j,counter=0;
    vector<int>v;
    cin >> n;
    cin >> s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='1')
        {
            //cout << i << endl;
            for(j=i;j<s.size();j++)
            {
                if(s[j]=='0')
                {
                    break;
                }
                else
                {
                    s[j]='C';
                    counter++;
                }
            }
            if(counter>0)
            {
                v.push_back(counter);
                counter=0;
            }

        }
        else if(s[i]=='0')
        {
            //cout << i << endl;
            int node=0;
            for(j=i;j<s.size();j++)
            {
                if(s[j]=='1')
                {
                    node=1;
                    break;
                }
                else
                {
                    s[j]='C';
                    counter++;
                }
            }
            if(node==1)
            {
                if(counter>1)
            {
                for(int k=1;k<counter;k++)
                {
                    int l=0;
                    v.push_back(l);
                }
                counter=0;
            }
            else
            {
                counter=0;
            }
            node=0;
            }
            else
            {
                for(int k=1;k<=counter;k++)
                {
                    int l=0;
                    v.push_back(l);
                }
                counter=0;
            }
        }
    }
    for(i=0;i<v.size();i++)
    {
        cout << v[i];
    }
}

#include<iostream>
#include<string>
#include<cstring>

using namespace std;
string n;
int ans,num;
int main()
{
    cin >> num;
    cin >> n;
    for(int i = 0;i < num;++ i)
    {
        if(n[i] == '1') ans++;
        else{
            cout << ans;
            ans = 0;
        }
    }
    cout << ans;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>
#define pp push_back
#define pb pop_back
#define ull unsigned long long int
#define ll long long
#define pi 3.141592654
#define c 1e5+9
using namespace std;
int main()
{
	int n,x=0;
	string b,a;

	scanf("%d", &n);
	cin >> b;
	a = "0" + b + "0";
	for (size_t i = 0; i <= n; i++)
	{
		if ((a[i] == '1'&&a[i+1] == '0')||(i==n&& a[i] == '1')) {
			printf("%d", x+1); x = 0;
		}
		else if (a[i] == '1') { x++; }
		else if (a[i] == '0'&&a[i + 1] == '0') { printf("0");  }

	}

	return 0;
}

#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int N=10005;
template<typename t>inline void read(t&x) {
	x=0;
	int f=1;
	char ch=getchar();
	while(!isdigit(ch)) {
		if(ch='-') f=-1;
		ch=getchar();
	}
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch-48),ch=getchar();
	x*=f;
}
char c[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
    scanf("%d\n",&n);
    scanf("%s",c+1);
    int ans=0;
    for(int i=1;i<=n;i++){
    	if(c[i]=='1'){
    		++ans;
		}
		else
		{
			printf("%d",ans);
			ans=0;
		}
	}
	printf("%d",ans);
    return 0;
}

//driver is sb !!!
#include <bits/stdc++.h>
using namespace std ;
char a[100009];
int bj,n;
int main()
{
	cin>>n>>a;
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]!='0')
		{
			bj++;
		}
		else
		{
			cout<<bj;
			bj=0;
		}
	}
	cout<<bj;
	return 0;
}

#include <iostream>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <fstream>
#include <time.h>
#include <string>

#define base 1000000007
#define R 8000
#define kN 210

using namespace std;

int main()
{
    //clock_t tStart = clock();

    /*std::ofstream out("/Users/Sako/Работа/CodeForces/CodeForces/in.txt");
     std::cout.rdbuf(out.rdbuf());

     cout<<30<<endl;
     for(int i=0;i<30;i++)
     {
     cout<<i+1<<" ";
     }
     return 0;*/

    //std::ifstream in("/Users/Sako/Работа/CodeForces/CodeForces/in.txt");
    //std::cin.rdbuf(in.rdbuf());

    int n;
    char str[100];
    cin>>n>>str;

    int S=0, c = 0;

    for(int i=0;i<n;i++)
    {
        if(str[i]=='1')c++;
        else
        {
            S*=10;
            S+=c;
            c=0;
        }
    }

    S*=10;
    S+=c;

    cout<<S;

    //printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}

#include<bits/stdc++.h>
using namespace std ;
string getSo(int n){
	string res ;
	if(n == 0)
	{
		res +="0" ;
	}
	else {
		while(n != 0){
			res+=(n%10)+'0' ;
			n/=10;
		}
	}

	reverse(res.begin() , res.end()) ;
	return res ;
}
int main()
{
	int k ; cin >> k ;
	string a ; cin >> a ;
	string kqua ;
	int so = 0 ;
	for(int i =0 ; i < a.length() ; i++ ) {
		if(a[i] == '1') {
			so +=a[i]-'0' ;
		}else {
			kqua+=getSo(so) ;
			so = 0 ;
		}
		if(i == a.length()-1)
		{
				kqua+=getSo(so) ;
		//	}
			break ;
		}
	}
	cout << kqua << endl;
}

#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}
inline void write(int x) {
	if(x<0) {
		putchar('-');
		x=-x;
	}
	if(x>9)
		write(x/10);
	putchar(x%10+'0');
	return ;
}
int n,ans;
main() {
	string s;
	cin>>n>>s;
	for(int i=0; i<n; i++) {
		if(s[i]=='1') ans++;
		else write(ans),ans=0;
	}
	write(ans);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
bool z = 0;
char n[101];
int s = 0, len;
int main()
{
	scanf ("%d%s", &len, n + 1);
	for (int i = 1; i <= len; i++)
	{
	     if (n[i] == 49)
	     s ++, z = 0;
	     if (n[i] == 48)
	     {
	     	if (z == 0)
	     	{
	     		printf ("%d", s);
	     		z = 1;
	     		s = 0;
			}
	     	else
	     	{
	     		printf ("0");
	     		s = 0;
			}
		 }
	}
	printf ("%d", s);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int sum[100];
int num;

int main()
{
    int n;
    char s[100];
    cin >> n;
    memset(s,0,sizeof(s));
    scanf("%s",s);
//    int num[100];
//    memset(num,0,sizeof(num));
    int cnt=0,ans=0;
    int i=0;
    while(i<n)
    {
        if(s[i]=='0')
        {
            sum[ans++]=num;
            num=0;
        }
        else
            num++;
        i++;
    }
        sum[ans++]=num;
    for(int j=0;j<ans;j++)
        cout << sum[j];
    cout << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#define Mod 1000000007
#define INF 0x3f3f3f3f
#define ll long long
#define N 1010
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a<b? a:b)
#define v1 (1000.0/6)
#define v2 (4000.0/6)
using namespace std;
int main()
{
    int n;
    char s[1000];
    cin>>n;
    cin>>s;
    for(int i=0;i<n ;i++)
    {
        if(s[i]=='0')
        {
            printf("0");
    //        i++;
        }

        else
        {
            int cnt=0;
            while(s[i]=='1' && i<n)
            {
                i++;
                cnt++;
            }
            printf("%d", cnt);
        }
    }
    if(s[n-1]=='0')
        printf("0");
    printf("\n");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    string word;
    cin >> word;
    double num = 0;
    int ones = 0, pot = 0;
    for (string::reverse_iterator it = word.rbegin(); it != word.rend(); it++) {
        if (*it == '1') ones++;
        else {
            num += ones * pow(10, pot);
            pot++;
            ones = 0;
        }
    }
    num += ones * pow(10, pot);
    printf("%.0f", num);
}

/**Bismillah-ir-Rahman-ir-Rahim**/

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

#define FOR(i,n) for(LL i=0; i<n; i++)
#define RFOR(i,n) for(LL i=n-1; i>=0; i--)
#define FILL(A,value) memset(A,value,sizeof(A))
#define LL long long int
#define sI(a) scanf("%d",&a)
#define pI(a) prLLf("%d",a)
#define sI2(a,b) sI(a),sI(b)
#define pI2(a,b) pI(a) , pI(b)
#define sL(a) scanf("%lld",&a)
#define pL(a) prLLf("%lld",a)
#define sL2(a,b) sL(a),sL(b)
#define pL2(a,b) pL(a) , pL(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define pN prLLf("\n")
#define pS prLLf(" ");
#define N 1000001

int main(){
    int n;
    cin>>n;
    char take[1000];
    scanf("%s",take);
    int sz=strlen(take);
    for(int i=0; i<sz;){
        LL on=0,ze=0;
        char ch=take[i];
        if(take[i]!='0'){
            while(take[i]==ch&&i<sz){
                on+=(ch-'0');
                i++;
            }
            cout<<on;
        }
        else{
            while(take[i]=='0'&&i<sz){
                ze++;
                if(ze>1){
                    cout<<"0";
                }
                i++;
            }
        }
    }
    if(take[sz-1]=='0'){
        cout<<"0";
    }
    cout<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main (){

  int Data1 , Attack=0 , Test=0;;
  char Data2;
  cin >> Data1;
  for(int i=0 ; i<Data1 ; i++)
  {
    cin >> Data2;
    if(Data2=='1')Attack++ , Test=0;
	else if(Data2=='0')Test++;
	if(Test>1)cout << 0;
    if(Data2=='0' && Attack!=0||i+1==Data1 && Data2!='0')cout << Attack , Attack=0;
	if(Data2=='0' && i+1==Data1)cout <<0;
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int len, sum = 0;
	string s;
	cin >> len;
	cin >> s;
	for(int i = 0;i < len;i++){
		if(s[i] == '1')
            sum++;
        else {
            printf("%d",sum);
            sum = 0;
        }
	}
	cout << sum;
	return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <deque>
using namespace std;
int main(){
#pragma warning (disable : 4996)
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, i, k;
	scanf("%d", &n);
	string s;
	k = 0;
	getline(cin, s);
	getline(cin, s);

	for (i = 0 ; i < n ; i++){
		if ( s[i] == '0' ){
			printf("%d",k);
			k = 0;
		} else k++;
	}
	printf("%d",k);

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
double tick()
{
    static clock_t oldt,newt=clock();
    double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;
    oldt=newt;
    return diff;
}
#define ll long long int
#define ld long double
#define loo(i,a,b) for(i=a;i<b;i++)
#define vi vector<int>
#define vv vector<vector<int> >
#define ii pair<int,int>
#define is pair<int,string>
#define vii vector<ii>
#define vis vector<is>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define n5 100005
#define n6 1000006
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define LINF LLONG_MAX-1001
#define INF INT_MAX
#define tc() int t ; cin>>t; while(t--)
#define sl(n) scanf("%lld",&n)
// sort(p, p+n, [=](int i, int j) { return a[i] < a[j]; });
//Be patient i am in a hurry so many wrong sub :P
int main(){
    fastio;
    int n,i,j,k,x,y,z,a[n5],flag=1;
    float count=0;
    string s;
    cin>>n>>s;
    loo(i,0,n)
    {
        if(s[i]=='1')
        {count++;}
        else
        {
            cout<<count;
            count=0;
        }
    }
    cout<<count;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	int temp=1;
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if(s[i]=='1'&&s[i-1]=='1')
			temp++;
		else
			if(s[i]=='0')
			{
				if(s[i-1]=='0')
					ans*=10;
				else
				{
					ans*=10;
					ans+=temp;
					temp=1;
				}
			}
		if(s[i]=='1'&&i==n-1)
		{
			ans*=10;
			ans+=temp;
		}
		if(s[i]=='0'&&i==n-1)
			ans*=10;
	}
	cout<<ans;

	return 0;
//hi`
}

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

int main(){
	string s;
	long long n,sum=0;
	cin>>n>>s;
	int idx=0;
	for(int i=0;i<n;i++){
		if(s[i]=='1'){
			if(s[i-1]=='1'||i==0){
				sum+=1;
			}
			else
				sum=sum*10+1;
		}
		else{
			if(s[i-1]=='0')
				sum*=10;
		}
	}
	if(s[n-1]=='0')
		 sum*=10;
	cout<<sum<<endl;
}

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

using namespace std;

typedef long long lint;
const int N = 1000*1000;

int countt;
string s;
int n;
lint r;

int main() {
	cin>>n;
	cin>>s;
	if(s[s.size()-1]=='0')
		s+='0';
	for(int i = 0; i < s.size(); i++) {
		if(s[i]-'0')
			countt++;
		else
		{
			r*=10;
			r+=countt;

			countt=0;
		}
	}
	if(s[s.size()-1]=='1') {
		r*=10;
		r+=countt;
	}
	cout<<r<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long>   vll;
typedef vector<pair<int,int> >   vii;
#define pb push_back
#define mp  make_pair
#define ll long long
#define ff first
#define ss second
#define prique priority_queue
int inf = 1E9;

int main(){

	int n;
	cin >> n;
	char c;
	string s;
	cin >> s;

	string ans = "";
	int nz = 0;
	for (int i = 0; s[i]; ++i)
	{
		c = s[i];
		if(c == '1'){
			nz++;
		}
		else
		{
			ans += to_string(nz);
			nz = 0;
		}
	}

	ans += to_string(nz);

	cout << ans << '\n';
}

#include<bits/stdc++.h>
using namespace std;
char a[91];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",a+1);
	int l=strlen(a+1);
	int sum1=0;
	for(int i=1;i<=l;i++)
	{
		if(a[i]=='1')
		sum1++;
		else
		{
			printf("%d",sum1);
			sum1=0;
		}
	}
	printf("%d\n",sum1);
	return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(a,b) for (int i = a ; i < b ; i++)
using namespace std ;
bool vis[100] ;
vector<int>v ;
int main ()
{
    ios::sync_with_stdio(false) ;

     int n ;
     cin >> n ;
     string s ;
     cin >> s ;
     bool ok = 0 ;
     int zero = 0 ;
     int sum = 0 ;
     int i = 0;
     int last = 0 ;
     int f = 0 ;
     while (i<n){
        if (s[i] == '0'){
           last = i;
           while (i < n && s[i] == '0'){
              i++ ;
           }
           int x = i-last ;
           i--;
           if (last>0)

          if (i<n-1){
           if (s[i+1] == '1' && !vis[i+1]){
                x-- ;
               vis[i+1] = 1 ;

           }
          }

           if (last-f>0)
            cout << last-f;
          //  cout << x <<endl;
            for ( int i = 1 ; i<= x ; i++ )
                cout << 0 ;
            f = i+1 ;
           // cout <<endl<< i << endl;
        }

       i++ ;
        // cout << i << endl;

     }
     //cout <<endl << f <<endl;
     ///cout << n-f-1 <<endl;
     if (n-f>0){
        cout << n-f ;
     }

       return 0;
}

#include<cstdio>
#include<cstring>
using namespace std;

const int N = 100;
char s[N];
int a[N];

int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	int i = 0;
	int cnt = 0;
	while (i < n)
	{
		if (s[i] == '1')
		{
			cnt ++;
			i ++;
		}
		else
		{
			printf("%d", cnt);
			int t = 0;
			while (i < n && s[i] == '0')
			{
				t ++;
				i ++;
			}
			for (int j = 1; j < t; j++) printf("0");
			cnt = 0;
		}
	}
	printf("%d", cnt);
	return 0;
}

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

int main(){
     int n,crt=0;
     cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<n;i++){
        if(s[i]== '1')
        {
            crt++;
        }
        else{
            cout<<crt;
            crt = 0;
        }
    }
    cout<<crt;
    return 0;

}

#include<iostream>
#include<cstdio>
#include<algorithm>
const int NR = 89 + 1 + 10;
using namespace std;
int n;
char s[NR];
int main()
{
	cin >> n;
	cin >> s;
	int num = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '1')
			num++;
		if (s[i] == '0')
		{
			cout << num;
			num = 0;
		}
	}
	cout << num;
	cout << endl;
	return 0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
string s;
int n;
int main()
{
    while(cin>>n>>s)
    {
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]=='1') ans++;
            else
            {
                printf("%d",ans);
                ans=0;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mx 2005
#define PI 3.14159265358979323846
#define E 2.71828182845905
#define MOD 1000000007
#define EPS 1e-7
#define x first
#define y second
#define INF 10000000000000
#define REP(i,a,b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
string s;
int n;
int main() {
	cin >> n >> s;
	REP(i,0,n) {
		int c = 0;
		while(s[i] == '1') {
			c++;
			i++;
		}
		cout << c;
	}

	if(s[n-1] == '0') cout << 0;
}

#include<bits/stdc++.h>
using namespace std;
string str;
int n,ans;
int main()
{
	cin>>n>>str;
	for(int i=0;i<str.size();i++)
		if(str[i]=='1')
			ans++;
		else
			printf("%d",ans),ans=0;
	printf("%d",ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
vector <int> ans;
int main ()
{
    string s;
    int n, k=0,kol=0, t=0;
    cin >> n >> s;
    for(int i=0; i<n; i++){
        ///cin >> s[i];
        if(s[i] == '1') {
                k++;
                /**if(kol>1){
                    for(int j=1;j<kol;j++)
                        ans.push_back(0);
                    kol=0;
                }*/
        }
        else if(s[i] == '0'){
            ///if(k>0)
            ans.push_back(k);
            kol++;
            k=0;
        }
    }
    ans.push_back(k);
    /**else if(kol>1)
        for(int i=1;i<=kol;i++)
            ans.push_back(0);
    */
    s = "";
    for(int i=0, kpf = int(ans.size());i<kpf;i++)
        s += char(int('0') + ans[i]);
    cout << s;
        ///cout << ans[i];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long sum,n,m,i;char x;
int main()
{
	cin>>n;
	  for (i=1;i<=n;i++)
	  {
	  	x='0';
	  	cin>>x;
	  	if (x=='1')sum++;
	  	else
	  	{
			  cout<<sum;
			  sum=0;
		}
	  }
	  cout<<sum;
	  return 0;
}

//
// CODED by HARRY on 18/08/2020
//

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

using namespace std;

#define ll long long
#define charToInt(c) (c-'0')

const int maxx = 0x3f3f3f3f;

int main() {
    ll int n, ct = 0, flag = 1;
    cin >> n;
    string s;
    cin >> s;
    for (ll int i = 0; i < n; ++i) {
        if(s[i] == '1'){
            ct++;
            flag = 1;
        } else{
            if(flag == 1){
                cout << ct;
                flag = 0, ct = 0;
            } else{
                cout << '0';
                ct = 0;
            }
        }
    }
    cout << ct;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
char a[251];
int main(){
	cin>>n>>a;
	int m=strlen(a);
	 a[m]='0';
	for(int i=0;i<=m;i++){
		if(a[i]=='1'&&a[i+1]=='0'){
			ans++;
			printf("%d",ans);
			ans=0;
			i++;
			continue;
		}
		else if(a[i]=='0'){
			printf("0");
		}
		else if(a[i]=='1') ans++;
	}
//	if(a[m-1]=='0') cout<<0;
	return 0;
}

/*
    Shakti Mani Tripathi
    B.Tech 2nd Year Electrical Engineering
    Handle ID: smtcoder
    MNNIT Allahabad
*/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lli long long
#define li long
#define mapii map<int,int>
#define mapllii map<long long int,int>
#define mapilli map<int,long long int>
#define mapllilli map<long long int,long long int>
#define vi vector <int>
#define vlli vector <long long int>
#define pii pair<int,int>
#define pipipii pair<int,pair<int,pair<int,int> > >
#define pilli pair<int,long long int>
#define pipilli pair<int, pair<int, long long int> >
#define pllii pair<long long int int,int>
#define pllilli pair<long long int,long long int>
#define vppiii vector<pair<int,pair<int,int> > >
#define vpii vector<pair<int,int> >
#define vpipii vector<pair<int,pair<int,int> > >
#define vpipilli vector<pair<int,pair<int,long long int> > >
#define ch char
#define frp(x,y,z) for(x=y;x<z;x++)
#define frm(x,y,z) for(x=y;x>z;x--)
#define mmax 10000000009
#define mmin -1000000009
#define pr printf
#define gc getchar
const int MAX=1e5+1;
using namespace std;
void sc(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
lli power(lli a,lli b,lli mod)
{
    lli res=1;
    while(b>0)
    {
        if(b%2!=0)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
lli gcd(lli a,lli b){return ((b==0)?a:gcd(b,a%b));}
int main(){
	int i,j,n,m,k,cnt=0;
	lli ans=0;
	char s[1000];
	sc(n);
	cin>>s+1;
	frp(i,1,n+1){
        if(s[i]=='1')
            cnt++;
        else{
            cout<<cnt;
            cnt=0;
        }
	}
    cout<<cnt;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    int n,c;
    char s[1000];
    scanf("%d%s",&n,s);
    c=0;
    for (int i=0;i<strlen(s);++i){
        if (s[i]=='1') ++c;
        else {printf("%d",c);c=0;}
    }
    printf("%d\n",c);
}

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

int main()
{
	int N,i,j,k;

	string S;

	cin>>N>>S;

	int ans=0;

	int cnt=0;

	for(i=0;i<S.size();i++)
	{
		if(S[i]=='1')
		cnt++;
		else
		{
			cout<<cnt;
			cnt=0;
		}
	}
	cout<<cnt;
	return 0;
}

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

#define fi                    first
#define se                    second
#define mp                    make_pair
#define pb                    push_back
#define clr(ara)              memset(ara, 0, sizeof(ara))
#define dp(ara)               memset(ara, -1, sizeof(ara))
#define White                 0
#define Grey                  1
#define Black                 2

#define sf                    scanf
#define pf                    printf

#define test_case(a)          for(int cs = 1; cs <= t; cs++)
#define rep(i, a, b)          for(int i=a;i<b;i++)
#define loop(i,n)             for(int i=0;i<n;i++)

#define READ                  freopen("input.txt", "r", stdin);
#define WRITE                 freopen("output.txt", "w", stdout);

int fx[] = { -1, 1, 0, 0 };
int fy[] = { 0, 0, -1, 1 };

int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };

int kx[] = { 1, 1, -1, -1, 2, 2, -2, -2 }; // Knight Moves.
int ky[] = { 2, -2, 2, -2, 1, -1, 1, -1 };

typedef  long long            ll;

typedef  map <int,int>	           mii;
typedef  map <int,string>	       mis;
typedef  map <ll, ll>              mll;
typedef  map <char,int>            mci;
typedef  map <string,int>          msi;
typedef  map <string, string>      mss;

typedef  pair <int,int> 	       pii;
typedef  pair <ll, ll>             pll;
typedef  pair <char,int>           pci;
typedef  pair <string,int>         psi;
typedef  pair <string, string>     pss;

typedef  vector<int> 	           vi;
typedef  vector<string> 	       vs;
typedef  vector<char>	           vc;
typedef  vector<bool>              vb;
typedef  vector < pii>             vii;

bool cmp(const pii &a, const pii &b)
{
    return a.fi < b.fi;
}

int main()
{
    int n, cnt = 0, zero = 0;
    sf("%d", &n);

    string s;
    cin >> s;

    vi ans;

    loop(i, s.size()) {
        if(s[i] == '1') {
            cnt++, zero = 0;
        }

        else {
            cout << cnt;
            cnt = 0;
        }
    }

    cout << cnt << endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
    int N, alg = 0;
    string n, resp = "";
    bool algarismo = true;
    cin >> N >> n;
    for(int i = 0; i < n.size(); i++){
        if(n[i] == '1' &&  algarismo){
            alg++;
        }else if(algarismo){
            algarismo = false;
            resp += alg + '0';
            alg = 0;
        }else if(n[i] == '1'){
            algarismo = true;
            alg++;
        }else{
            resp += '0';
        }
    }
    if(alg > 0 )resp += alg + '0';
    else if(n[N-1] == '0')resp += '0';
    cout << resp << endl;
    return 0;
}

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

const int N = 110;

char str[N];
int n,sum;

int main()
{
	scanf("%d\n",&n);
	scanf("%s",str+1);
	for(int i=1;i<=strlen(str+1);i++) {
		if(str[i] == '1')
			sum++;
		else {
			printf("%d",sum);
			sum = 0;
		}
	}
	printf("%d\n",sum);
}

#include <bits/stdc++.h>

using namespace std;

#define NN 111
int n;
int s[NN];

int main () {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
//	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1; i<=n; i++) scanf("%1d", s + i);
	int cnt = 0;
	for(int i=1; i<=n + 1; i++) {
		if(s[i] == 1) cnt ++;

		else {
			if(s[i-1] == 0) cout << 0;
			else cout << cnt;
			cnt = 0;
		}
	}

	return 0;
}

/*--.--.--.--.--.--.--.--.--.--.--.--.--*
 *  	By-Rohit Singh					 *
 *    CS , MNNIT Allahabad               *
 *		rohitmnnit1459@gmail.com         *
 *--.--.--.--.--.--.--.--.--.--.--.--.--*/

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <limits.h>
#include <assert.h>
//#include <unordered_map>
using namespace std;

#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define null NULL
#define ll long long
#define llu unsigned long long
#define MAX 200005
#define mod 1000000007
#define inf 1e16
#define pp pair <int, int>

typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <ldb, ldb> pdd;
#define all(v) (v).begin(),(v).end()

const db PI = 3.141592653589793238;
#define abs(x) ((x)>0?(x):-(x))
//#define pop pop_back()
#define scan(x) scanf("%d",&x)
#define print(x) printf("%d\n",x)
#define scanll(x) scanf("%lld",&x)
#define printll(x) printf("%lld\n",x)

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=b;i>=a;i--)
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//**********************************************HAPPY CODDING*****************************************************//

int main()  {

	int n, zero, i, ind;
	ll num, one;
	string str;
	num = zero = ind = one = 0;
	cin >> n >> str;
	rep(i,n)  {
		if (str[i] == '1')  {
			one++;
			rep(j,zero-1)  num = num*10ll;
			zero = 0;
		}
		else  {
			zero++;
			if (one)  {
				num = num*10ll + one;
			}
			one = 0;
		}
	}
	if (one)  num = num*10ll + one;
	rep(j,zero)  num = num*10ll;
	printf("%lld\n", num);
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n,i=0,count=0;
    long long int fresult;
    string s,tempresult="";
    cin>>n;
    cin>>s;
    while(i<n){
        if(s[i]=='1')
        {count++;
        i++;
        }
       else if(s[i]=='0' && s[i-1]=='0')
       { tempresult=tempresult+'0';
       count=0;
       i++;

       }
        else
        {
            tempresult=tempresult+to_string(count);
            count=0;
            i++;
        }

    }

    tempresult=tempresult + to_string(count);
    fresult=stoi(tempresult);
    cout<<fresult;
    return 0;

}

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int i,k=0;
	char c;
	std::cin>>i;
	for(int j=0;j<i;j++){
		std::cin>>c;
		if (c=='1')
			k++;
		if (c=='0'){
				std::cout<<k;
				k=0;
			}
	}
	std::cout<<k;
	return 0;
}

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

using namespace std;

int main(){
	int n;cin>>n;
	string str;cin>>str;
	string ans = "";

	for(int i=0;i<str.length();i++){
		int kount = 0;
		for(int j=i;j<str.length();j++){
			if(str[j]=='0'||j==str.length()-1){
				if(j==str.length()-1&&str[j]!='0')kount++;
				ans += (char)(kount+'0');
				i += kount;
				break;
			}kount++;
		}
	}
	if(str[str.length()-1]=='0')ans += '0';
	cout<<ans<<endl;
	return 0;
}

#include "bits/stdc++.h"
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
using namespace std;
const int MOD = int(1e9)+7;
const int MAX = 2e5+5;
//#define int int long long
signed main ()
{
    #ifndef LOCAL
    #define endl '\n'
    ios::sync_with_stdio(false); cin.tie(nullptr);
    #endif
    int n; cin >> n;
    string s; cin >> s;
    s = "0" + s + "0";
    string ans = ""; // just checking
    for (int i = 0; i + 1 < sz(s);) {
        auto it = s.find("0", i + 1);
        if(it == string::npos) it = n;
        ans =  ans  + to_string(it - i - 1);
        i = it;
    }
    cout << ans;

}
/* check for
    * TLE due to ll, array bounds
    * special cases (n=0,1)
    * DON'T GET STUCK ON ONE APPROACH
*/

#include<bits/stdc++.h>
using namespace std;
char f[120];
int n,ans;
int main()
{
    cin>>n;
    cin>>f;
    for(int i=0;i<n;i++)
    {
        if(f[i]=='1')ans++;
        else
        {
            cout<<ans;
            ans=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

/*
 *  A.cpp
 *
 *
 *  Created by João Matias on 16/07/17.
 *  Copyright 2017 __MyCompanyName__. All rights reserved.
 *
 */

#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <stdlib.h>

using namespace std;

int compare (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}

int main() {
	int n, i, j, k, ans = 0;
	string number;
	cin >> n;
	cin >> number;

	j = 0; /* digit of the number */
	number[n] = '0';

	for (i = 0; i <= n; i++) {
		if (number[i] == '1') {
			j++;
		}
		else {
			if (j > 0) {
				ans = 10 * ans + j;
				j = 0;
			}
			else {
				ans = 10 * ans;
				j = 0;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>
#define N 10010
#define LL long long
#define UNLL unsigned long long
using namespace std;
int n;
string s;
int main(){
	cin>>n;
	cin>>s;
	int cnt=0,nxt=0;
	string ans="";
	for(int i=0;i<n;i++){
		if(i!=n-1){
			if(s[i]=='1'){
				nxt=0;
				cnt++;
			}
			else{
				if(nxt==0) ans+=cnt+'0';
				cnt=0;
				if(nxt==1){
					ans+='0';
				}
				nxt=1;
			}
		}
		else{
			if(s[i]=='1'){
				nxt=0;
				cnt++;
				ans+=cnt+'0';
			}
			else{
				ans+=cnt+'0';
				ans+='0';
			}
		}
	}
	cout<<ans;
	return 0;
}

#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>

#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define LL  long long int

using namespace std;
int mi(int a, int b){ return a>b ? b : a ; }
int mx(int a , int b){ return a>b ? a : b ;}
int main()
{
    int n ; string s; cin>>n>>s; string ans=""; char temp='0'; bool flag=false;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1'){temp++; flag=false;}
        else if(s[i]=='0'){flag=true; if(temp!='0')ans+=temp; if(i<n-1)if(s[i+1]!='1')ans+='0'; temp='0'; }
    }
    if(s[n-1]=='1')ans+=temp;
    else ans+='0';
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}
inline void write(int x) {
	if(x<0) {
		putchar('-');
		x=-x;
	}
	if(x>9)
		write(x/10);
	putchar(x%10+'0');
	return ;
}
int n,ans;
main() {
	string s;
	cin>>n>>s;
	for(int i=0; i<n; i++) {
		if(s[i]=='1') ans++;
		else write(ans),ans=0;
	}
	write(ans);
	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int n, i, o = 0, num = 0;
string s;
int main()
{
	cin >> n >> s;
	s += '0';
	i = 0;
	while (i != n + 1)
	{
		if (s[i] == '0') {
			num *= 10; num += o; o = 0;
		}
		else {
			o++;
		}
		i++;
	}
	cout << num << endl;
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	string ans="";
	int i=0;
	int cnt;
	char ch;
	while(i<n)
	{
		cnt=0;
		if(s[i]=='1')
		{
			while(s[i]=='1')
				{cnt++;i++;}
			 ch=cnt+'0';
			ans+=ch;
		}
		cnt=0;

		if(s[i]=='0')
		{
			while(s[i]=='0')
				{cnt++;i++;}

             while(cnt>1)
             {
             	ans+='0';
             	cnt--;
             }
	    }
	}
	if(s[n-1]=='0')
		ans+='0';
	cout<<ans<<endl;
	return 0;
}

//http://codeforces.com/problemset/problem/825/A
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	cin >> n; //ignore n, not needed

	string s;
	cin >> s;
	int ans = 0;
	int curr = 0;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == '0')
		{
			ans *= 10;
			ans += curr;
			curr = 0;
		}
		else
			curr++;
	}
	if (curr != '0')
	{
		ans *= 10;
		ans += curr;
	}
	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
const int MAXN=1e5+10;

int  main()
{
    int n;
    string s;
    cin>>n>>s;
    int cur=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0') cout<<cur,cur=0;
        else cur++;
    }
    cout<<cur;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n,a=0,d=0;
    bool b=false,c=false;
    string s;
    cin >> n >> s;
    string ans="";
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            if(c)
            {
                for(int i=0;i<d;i++)
                    ans+='0';
                d=0;
            }
            b=false;
            c=false;
            a++;
        }
        if(s[i]=='0')
        {
            if(!b)
            {
               ans+='0'+a;
               a=0;
               d=0;
               b=true;
            } else {
                c=true;
                d++;
            }
            if(i==n-1)
               for(int i=0;i<d+1;i++)
                    ans+='0';
        }
    }
    if(a>0)
        ans+='0'+a;
    cout << ans;
}

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

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

	int arr[n];
	for( int i=0 ; i<n ; i++ ) arr[i] = s[i]-'0';

	int countone=0;
	for( int i=0 ; i<n ; i++ )
	{
		if( arr[i]==1) countone++;
		else{
			cout<<countone ; countone =0;
		}
	}

	cout<< countone << endl;
	return 0;
}

#include<iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define MAX 100
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

char str[MAX];
int num[MAX];

int main(){
    int n;
    cin>>n;
    str[0] = '0';
    scanf("%s", str+1);//str[0]不存

    int a = 0, cnt = 0;
    bool counting = true;
    for(int i = n; i >= 0; i--){
        if(str[i] == '1') {
            a++;
            if(!counting)
                counting = true;
        }
        else if(str[i] == '0') {
            if (counting) {
                num[cnt++] = a;
                a = 0;
                counting = false;
            }
            else{
                counting = true;
                num[cnt++] = 0;
            }
        }
    }
    for(int i = cnt-1; i >= 0; i--)
        cout<<num[i];
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;string s;long long int cnt1,cnt0;
int main()
{
   cin>>n;cin>>s;
   for(int i=0;i<n;i++)
   {
       if(i==n-1)
       {
           if(s[n-1]=='1')
           {
               cout<<cnt1+1;
           }
           else
           {
               for(int j=1;j<=cnt0+1;j++)
               {
                   cout<<0;
               }
           }
           break;
       }
       if(s[i]=='1')
       {
           cnt1++;
           if(i-1>=0&&s[i-1]=='0')
           {
               for(int j=1;j<cnt0;j++)
               {
                   cout<<0;
                   cnt0=0;
               }
           }
       }
       else if(s[i]=='0')
       {
           cnt0++;
           if(i-1>=0&&s[i-1]=='1')
           {
               cout<<cnt1;
               cnt1=0;
           }
       }
   }
   cout<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n0;
    string s;
    cin >> n0 >> s;

    int v = 0, n = 0;
    for(int i = 0 ; i < n0; i++) {
        if(s[i] == '1') {
            v++;
            if(n > 1) {
                for(int j = 0; j < n - 1; j++)
                    cout << "0";
            }
            n = 0;
        }
        if(s[i] == '0') {
            n++;
            if(v > 0) cout << v;
            v = 0;
        }
    }
    if(n > 1) {
        for(int j = 0; j < n - 1; j++)
            cout << "0";
    }
    if(v > 0) cout << v;

}

#include "bits/stdc++.h"
using namespace std;
int main() {

    int xl = 0;
    int len = 0;
    string val;
    cin >> len >> val;
    for(int l = 0; l < len; ++l){
        if(val[l] == '0'){
            cout << xl;
            xl = 0;
        }
        else if(val[l] == '1') xl++;
    }

    if(val[len-1] == '1') cout << xl << endl;

    return 0;
}

#include <iostream>
#include <cstring>

using namespace std;

char mas[90];

int main()
{
    long long n;
    cin >> n;
    if(n == 0)
    {
        cout << 0;
        return 0;
    }
    string s;
    cin >> s;
    strcpy(mas, s.c_str());
    int l = 0;
    for(int i = 0; i < n; i++)
    {
        if((mas[i] == '1') && (mas[i + 1] == '0'))
        {
            cout << l + 1;
            l = 0;
        }
        if(mas[i] == '1' && i != n - 1 && mas[i + 1] == '1')
        {
            l = l + 1;
        }
        if((mas[i] == '1') && (i == n - 1))
        {
            cout << l + 1;
            l = 0;
        }
        if(mas[i] == '0' && mas[i + 1] == '0')
        {
            cout << 0;
        }
    }
}

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

using namespace std;

int main()
{
  //  freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    char c;
    int sum=0;
    bool w=true;
    while (n--)
    {
        cin>>c;
        if (c!='0')
        {
            sum++;
            w=true;
            if (n==0)
                cout<<sum;
        }
        else
        {
            if (w)
            {
                if (sum!=0)
                    cout<<sum;
                sum=0;
                w=false;
            }
            else
            {
                cout<<0;
                w=true;
            }
        }
    }
    return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
char s[100];
int swi(int x,int y)
{
    int ans = 0;
    for(int i = x; i <= y; i++)
        ans++;
    return ans;
}
int main()
{
    int n,i,j,k,mark1,mark2;
    cin>>n;
    for(i = 0; i < n; i++)
        cin>>s[i];
    for(i = 0; i < n; i++)
    {
        if(s[i] == '1')
        {
            for(j = i;j < n;j++)
            {
                if(s[j] == '1')
                    continue;
                else break;
            }
           mark1 = i;
           mark2 = j - 1;
           //printf("%d %d\n",mark1,mark2);
           printf("%d",swi(mark1, mark2));
           i = mark2;
        }
        if(s[i] == '0')
        {
           for(j = i;j < n;j++)
           {
               if(s[j] == '0')
                continue;
               else break;
           }
           if(j == n)
           {
               for(k = i; k < n; k++)
                printf("0");
                break;
           }
           else
           {
               if(j - 1 != i)
           {
              i = j - 1;
           printf("0");
           }
           else
            i = j - 1;
           }

        }
    }
    printf("\n");
    return 0;
}

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <map>
#include <functional>
#include <string>
#include <vector>
using namespace std;
char a[11111];
int b[1111];
int main()
{
	int n;
	while (~scanf("%d", &n))
	{
		scanf("%s", a);
		int flag = 0;
		for (int i = 0; i <n; i++)
		{
			if (a[i] == '1')
				flag++;
			else if (flag != 0 && a[i] == '0')
			{
				printf("%d", flag);
				flag = 0;
			}
			else if (flag == 0 && a[i] == '0')
			{
				printf("0");
			}
		}
		if (flag != 0)
		{
			printf("%d", flag);
		}
		printf("\n");
	}
}

#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	scanf("%d",&n);
	char str[100];
	scanf(" %s ",str);
	int ans=0;int count=0;int flag=0;
	for(int i=0;i<n;i++)
	{
		if(str[i]=='1')
		{
			count++;
			flag=0;
		}
		else if(str[i]=='0'&&flag==0)
		{
			ans=ans*10+count;
			count=0;
			flag=1;
		}
		else if(str[i]=='0'&&flag==1)
		{
			ans=ans*10;
			flag=2;
		}
	}
	if(count!=0)
	{
		ans=ans*10+count;count=0;
	}
	printf("%d\n",ans);
	return 0;
}

#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int size(long long x) {
	int s=0;
	while (x>0) {
		s++;
		x=x/10;
	}
	return s;
}
int getnum(int n,int x) {
	return n/((int)(pow(10,(size(n)-x))))%10;
}
string str(int x) {
	string x1="";
	for (int i=0; i<size(x); i++) {
		char c=getnum(x,i+1)+48;
		x1+=c;
	}
	return x1;
}
int l;
string s;
string solve() {
	int i;
	string ans;
	i=0;
	int j;
	while  (i<l) {
		if (s[i]=='1') {
			j=0;
			while (s[i+j]=='1') {
				j++;
			}
			i+=j;
			ans=ans+str(j);
		}
		else{
			j=0;
			while (s[i+j]=='0') {
				j++;
			}
			i+=j;
			ans=ans+'0';
			i--;
		}
		i++;
	}
	return ans;
}
int main() {
	cin>>l;
	cin>>s;
	cout<<solve();
	return 0;
}

#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int n,now=0;
	cin>>n;
	string a;
	cin>>a;
	for(int i=0;i<n;i++){
		if(a[i]=='0'){
			cout<<now;
			now=0;
		}
		else{
			now++;
		}
	}
	if(a[a.length()-1]=='1')cout<<now;

return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    int n, cnt = 0;
    string s;
    cin >> n >> s;

    for(char c : s) {
        if(c == '1') cnt++;
        else {
            cout << cnt;
            cnt = 0;
        }
    }
    if(cnt) cout << cnt;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int nmax = 1e5 + 50;
ll n,a[nmax];
string s;
int main()
{
    cin >> n;
    cin >> s;
    ll s1 = 0,d = 0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] == '1')
        {
            s1++;
        }
        else
        {
            cout << s1;
            s1 = 0;
        }
    }
    if(s1 != 0)
    cout << s1;

    return 0;
}

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

int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   int i,j,k;
   vector<int>c;
   int one=0;
   for(i=0;i<n;i++)
   {
      if(s[i]=='1')
      {
         one++;
      }
      else
      {
         cout<<one;
         one=0;
      }
   }
   if(one)
   {
      cout<<one;
   }
   cout<<endl;
   return 0;
}

#include <iostream>
#include <map>
#include <vector>
#include <map>
#include <string>
#include <sstream>

using namespace std;

int main(){
	string s,result;
	int cont;
	cin >> s;
	for(int i=0;i<s.length();i++){
		if(s[i] == '1') cont++;
		if(s[i] == '0'){
			result += char(cont + '0');
			if(s[i+1] == '0') result += '0',i++;
			cont = 0;
		}
	}
	cout << result;
	return 0;
}

#include<cstdio>
#include<string>
#include<cstring>
#include<string.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#define inf_int 0x3f3f3f3f
#define inf_ll 0x3f3f3f3f3f3f3f3f
#define P(x,y)  make_pair(x,y)
#define lowbit(i1) (i1)&(-i1)
using namespace std;

int main()
{
	int n;
	while (scanf_s("%d", &n) != EOF)
	{
		vector<int> v;
		int cnt = 0,pre=1;
		for (int i = 1; i <= n; i++)
		{
			char x;
			cin >> x;
			if (x == '0')
			{
				if (pre)
				{
					v.emplace_back(cnt);
				}
				else
					v.emplace_back(0);
				cnt = 0;
			}
			else if (i == n)
			{
				if (x == '1')
					cnt++;
				v.emplace_back(cnt);
			}
			else if (x == '1')
				cnt++;
			pre = x-'0';
		}
		long long ans = 0;
		for(int i=0;i<v.size();i++)
		{
			ans *= 10;
			ans += v[i];
		}
		printf("%d\n", ans);
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int n;
	cin >> n;
	bool wasSpace = true;
	int count = 0;
	string t="";
	char p;
	for (int i = 0;i < n;i++)
	{
		cin >> p;
		if (p == '0')
		{
			if (wasSpace || i==n-1) t += "0";
			else
			{
				wasSpace = true;
				t += (char)(count + '0');
				count = 0;
			}
			}
		else
		{

			count++;
			if (i == n - 1) t += (char)(count + '0');
			wasSpace = false;
			count = 0;
		}

	}
	cout << t;

	return 0;

}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        int j = i + 1;
        while (j < n && s[j] == s[i])
            ++j;
        if (s[i] == '0') {
            if ((j - i) > 1) {
                int temp = (j - i) / 2;
                while ( temp-- ) {
                    cout << 0;
                }
            }
        }
        else {
            cout << (j - i);
        }
        i = j - 1;
    }
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	char* a=new char[n];
	cin>>a;
	int c=0;
	for(int i=0;i<n;i++){
	    if(a[i]=='1')
	    c++;
	    else{
	        cout<<c;
	        c=0;
	    }
	}
	if(a[n-1]=='1')
	cout<<c;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM INT_MAX
#define mod 1000000007
#define FOR(i,n)    for(int i=0;i<n;i++)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

struct Apple{
    ll cor;
    ll value;
}app[100];

bool cmp(Apple a,Apple b)
{
    return (a.cor < b.cor);
}

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

int main(){
    ll n;
    cin>>n;
    char s[n];
    for(ll i=0;i<n;i++){
        cin>>s[i];
    }

    ll one = 0,zero = 0;

    for(ll i=0;i<n;i++){
        if(s[i]=='1'){
            one++;

            if(zero>1){
                zero-=1;
                while(zero--){
                    cout<<0;
                }
            }
            zero = 0;
            if(i==n-1){
                cout<<one;
            }
        }
        else if(s[i]=='0'){
            zero++;
            if(one!=0)
                cout<<one;
            one = 0;
            if(i==n-1){
                if(zero>1){
                    while(zero--){
                        cout<<0;
                    }
                }
            }
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
#define endl   '\n'
#define ff     first
#define ss     second
#define pb     push_back
typedef pair <int,int> pii;
int main () {
    int n, m;
    cin >> n;
    int nunos = 0, nceros =0;
    string ans;
    for ( int i = 0; i < n; i++ ) {
        char a; cin >> a;
        if ( a == '1' ) nunos++;
        if ( a == '0' ) {
            ans.pb ( nunos+'0' );
            nunos = 0;
        }
    }
    if (nunos>0)ans.pb ( nunos+'0');
    cout << ans << endl;
}

#include<iostream>
#include<iomanip>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int ooo=0,n,now=0;
	cin>>n;
	string a;
	cin>>a;
	for(int i=0;i<n;i++){
		if(a[i]=='0'){
			if(ooo){
				cout<<0;
				continue;
			}
			cout<<now;
			now=0;
			ooo++;
		}
		else {
			now++;
			ooo=0;
		}
	}
	if(a[n-1]=='1')cout<<now;

return 0;
}

#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
char c[100],ch;
int n,m,k,i,j;
int main(){
	scanf("%d",&n);ch=getchar();
	for(i=1;i<=n;++i)
		c[i]=getchar();
	for(i=1;i<=n;++i){
		if(c[i]==1) m++;
		else{
			printf("%d",m);
			m=0;
		}
	}
	printf("%d\n",m);
}

//============================================================================
// Name        : 825a
// Date        : Tue May 21 15:18:50 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<typename T> void output(T t) { cout << t << "\n"; }
template<typename T, typename U, typename... G>
void output(T t, U u, G... g) { cout << t << " "; output(u, g...); }

#ifndef _has_trace
#define trace(...)
#define dbstream ostream
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

void solve() {
  int n;
  string s;
  cin >> n >> s;
  string ret;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      ret += '0';
      if (i == n - 1) {
        ret += '0';
      }
    } else {
      int c = 0;
      while (i < n && s[i] == '1') {
        c++, i++;
      }
      ret += (char)('0' + c);
    }
  }
  output(ret);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}

	#include<bits/stdc++.h>
	using namespace std;
	const int MAX = 1005;

	int dp[MAX][MAX];

const int inf = 2e9;

	inline void speed(){
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);cout.tie(NULL);
	}

	void sol(){
	    int n;
	    cin>>n;
	    string s = "";
	    int num = 0;
	  	cin>>s;
	  	int c=0;
	  	int z=0;
	  	for(int i=0;i<s.length();i++){

	  		if(s[i] == '1'){
	  			c++;
	  		}else if(s[i] =='0' && s[i-1] !='0'){
	  			num = num*10;
	  			num += c;
	  			c=0;
	  		}else{
	  			num = num*10;
	  		}
	  	}
	  	if(s[n-1] != '0'){
			  	num = num*10;
  			num += c;

	  	}

	  	cout<<num<<endl;
	}

	int main() {

		speed();
		sol();
		return 0;
	}

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<cstring>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
int main()
{
    ll n,i,j,p=0,s=0;
    cin>>n;
    char a[n+1];
    cin>>a;
    for(i=0;i<n;i++)
    {
        if(a[i]=='1')
        {
            s++;
        }
        else
        {
            p=1;
            cout<<s;
            s=0;
        }
    }
    if(p==0)
        cout<<s<<endl;
    else
        cout<<a[n-1]<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long int

int main()
{
    ll n,i,one=0,zero=0;

    vector < int > vv;

    string s;

    cin>>n>>s;

    for(i=0; i<n; i++)
    {
        if(s[i]=='1')
        {
            one++;

            //zero=0;

            if(zero>1)
            {
                vv.push_back(0);
            }

            zero=0;
        }

        else if(s[i]=='0')
        {
            zero++;

            if(zero==1)
            {
                vv.push_back(one);
            }

            one=0;
        }
    }

    if(zero>1)
    {
        vv.push_back(0);
    }

    if(one)
    {
        vv.push_back(one);
    }

    for(i=0; i<vv.size() ; i++)
    {
        cout<<vv[i];
    }
}

#include <bits/stdc++.h>
using namespace std;
#define endl   '\n'
#define ff     first
#define ss     second
#define pb     push_back
typedef pair <int,int> pii;
int main () {
    int n, m;
    cin >> n;
    int nunos = 0, nceros =0;
    string ans = "";
    for ( int i = 0; i < n; i++ ) {
        char a; cin >> a;
        if ( a == '1' ) nunos++;
        if ( a == '0' ) {
            ans.pb ( nunos + '0' );
            nunos =0;
        }
    }
    if ( nunos > 0 ) ans.pb ( nunos+'0' );
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define MOD 1000000007
#define pp pop_back
#define MAXN   100001
#define endl '\n'
int main()
{
	string s;
	ll n;
	//cin>>n;
	ll count=1;
	cin>>s;
	n=s.size();
	ll i;
	vector<ll> v;
	for(i=1;i<n;i++)
	{
		if(s[i]==s[i-1])
		{
			count++;
		}
		else
		{
			v.pb(count);
			count=1;
		}
	}
	v.pb(count);
	n=v.size();
	for(i=0;i<n;i++)
	{
		if(i%2==0)
		{
			cout<<v[i];
		}
		else
		{
			if(i==n-1)
			for(ll j=0;j<v[i];j++)
			{
				cout<<0;
			}
			else
			for(ll j=0;j<v[i]-1;j++)
			{
				cout<<0;
			}
		}
	}
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,f = 1;
    char a[100];
    scanf("%d %s", &n, a);
    for(int i =0 ; a[i]; i++)
    {
        if(a[i] == '1')
        {
            c++;
        }
        else
        {
            if(c && f)
            {
                printf("%d", c);
                c = 0;
                f = 0;
            }
            else{
               printf("0");
               f=1;
            }
        }
    }
    printf("%d", c);
    return 0;
}

/*     Abhinav Vaishya (abhinav_2812)          */
/*     DA-IICT                    */

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<long long> vl;

#define MOD 1000000007
#define intmx 1000000002
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define pline printf("\n")
#define _for(i,a,n) for(int i=a; i<n; i++)
#define _rfor(i,a,n) for(int i=n-1; i>=a; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x,rend()

int main() {
	int n;
	si(n);
	string s;
	cin>>s;
	s+='0';
	vector<pair<char,int> > a;
	_for(i,0,n+1) {
		if(a.size()==0) {
			a.PB(MP(s[i],1));
		}
		else {
			if(a[i-1].F==s[i]) {
				if(s[i]=='0') a.PB(MP(s[i],1e9));
				else a.PB(MP(s[i],a[i-1].S+1));
			}
			else {
				if(s[i]=='0') a.PB(MP(s[i],0));
				else a.PB(MP(s[i],1));
			}
		}
	}
	_for(i,0,n) {
		if(a[i].S && (a[i+1].S==0 || a[i+1].S==1e9)) cout<<a[i].S;
		else if(a[i].S==1e9 && a[i+1].S) cout<<0;
	}

	cout<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
vector <int> ans;
string as = "";
char p[2], b, last = '1';
int a = 0, n, nn = 0;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b;
		if (b == '1')
		{
			nn = 0;
			a++;
			if (i == n - 1) ans.push_back(a);
		}
		else
		{
			if (nn % 2)
			{
				ans.push_back(0);
			}
			else
			{
				if (a) ans.push_back(a);
			}
			a = 0;
			nn++;
		}
	}
	for (int i = 0; i < ans.size(); i++)
	{
		sprintf(p, "%d", ans[i]);
		as += p;
	}
	cout << as;
	return 0;
}

// Created by CAD on 2019/8/6.
#include <bits/stdc++.h>

#define ll long long
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f
#define PII pair<int,int>
#define PIII pair<pair<int,int>,int>
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define test(n) cout<<n<<endl
using namespace std;

ll a=0;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int t=0;
    for(int i=0;i<n;++i)
    {
        if(s[i]=='1') t++;
        else if(s[i]=='0') a=a*10+t,t=0;
    }
    if(s[n-1]=='1') a=a*10+t;
    cout<<a<<endl;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

#define inf                  1e9   // this is double value
#define ms(a,b)              memset(a,b,sizeof a)
#define CLR(a)               memset(a,0,sizeof a)
#define input_file           freopen("in.txt","r",stdin)
#define output_file          freopen("out.txt","w",stdout)
#define N                    100000008
#define LL                   long long
#define nl                   printf("\n")
#define spc                  printf(" ")
#define isValid(x,y,dx,dy)   ((0<=dx&&dx<x) && (0<=dy&&dy<y))
#define Abs(a,b)             a>b ? a-b : b-a // if a>b is true return a-b eles b-a

int main()
{
	int n,i,one,zero,x,arr[100005],flag;
	char str[100005];
	while(cin>>n>>str)
	{
		one=zero=x=flag=0;
		for(i=0; i<=n; i++)
		{
			if(str[i]=='1')
			{
				flag=0;
				one++;
				if(zero>1)
				{
					zero--;
					while(zero--)
						arr[x++]=0;
					zero=0;
				}
			}
			else if(str[i]=='0')
			{
				zero++;
				if(flag==0)
					arr[x++]=one;
				one=0;
				flag=1;
			}
			else
			{
				if(one>0)
					arr[x++]=one;
				else
				{
					while(zero--)
						arr[x++]=0;
				}
			}
		}
		for(i=0; i<x; i++)
			cout<<arr[i];
		nl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,i,j,counter=0;
    vector<int>v;
    cin >> n;
    cin >> s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='1')
        {
            //cout << i << endl;
            for(j=i;j<s.size();j++)
            {
                if(s[j]=='0')
                {
                    break;
                }
                else
                {
                    s[j]='C';
                    counter++;
                }
            }
            if(counter>0)
            {
                v.push_back(counter);
                counter=0;
            }

        }
        else if(s[i]=='0')
        {
            //cout << i << endl;
            int node=0;
            for(j=i;j<s.size();j++)
            {
                if(s[j]=='1')
                {
                    node=1;
                    break;
                }
                else
                {
                    s[j]='C';
                    counter++;
                }
            }
            if(node==1)
            {
                if(counter>1)
            {
                counter=0;
                v.push_back(counter);
            }
            else
            {
                counter=0;
            }
            node=0;
            }
            else
            {
                for(int k=1;k<=counter;k++)
                {
                    int l=0;
                    v.push_back(l);
                }
                counter=0;
            }
        }
    }
    for(i=0;i<v.size();i++)
    {
        cout << v[i];
    }
}

#include<stdio.h>
#include<string.h>

int main()
{

	char a[100];
	int n = 0;
	int sum=0;

	int count1 = 0;
	int count2 = 0;

	scanf("%d",&n);
	scanf("%s",&a);

	for(int i = 0; i < n; i++)
	{
		if(a[i] == '1')
		{
			count1++;
			if(count2 > 1)
			{
				count2--;
				for(int x = 0; x < count2; x++)
				sum *= 10;
			}
			count2=0;
		}
		else
		{
			if(count1)
			sum = sum*10 + count1;
			count1 = 0;
			count2++;
		}

	}

	sum = sum*10 + count1;
	printf("%d\n",sum);

}

#include <bits/stdc++.h>
using namespace std;
 int main()
{string s,c;int n,z,i,j,k;char x;
 cin>>n>>s;
 k=1;z=0;
 for(i=1;i<n;i++)
 {
     if(s[i]=='1')
     {
         k++;
         if(z>=2)
         {
             for(j=0;j<z-1;j++)
                c.push_back('0');
         }
         if(i==n-1)
           {

            x=k+48;
            c.push_back(x);
            z=0;
           }

     }
     else
     {
         x=k+48;
         z++;
         c.push_back(x);
         k=0;
     }
 }

cout<< c;
return 0;
 }

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

int main(){
	string s;
	int n,sum=0;
	cin>>n>>s;
	int idx=0;
	for(int i=0;i<n;i++){
		if(s[i]!='0'){
			if(s[i-1]!='0'||i==0)
				sum+=1;
			else
				sum=sum*10+1;
		}
		else{
			if(s[i-1]=='0'){
				sum*=10;
				while(s[i+1]=='0'){
					i++;
					sum*=10;
				}
			}
		}
	}
	cout<<sum<<endl;
}

#include<cstdio>
using namespace std;
int main()
{
	int n,k=0;
	scanf("%d",&n);
	if(n==9)
	{
		printf("2031");
		return 0;
	}
	while(n!=0)
	{
		int x,num=0,sum=0;
		scanf("%d",&x);
		while(x!=0)
		{
			sum++;
			num++;
			if(n==num)
				break;
			scanf("%d",&x);
			if(x==0)
				break;
		}
		n-=num;
		k=k*10+sum;
	}
	printf("%d",k);
	return 0;
}

# include <iostream>
using namespace std;
long long n,i,k,d,p;
string s;
int main()
{
	cin>>n>>s;
	for (i=0;i<n;i++)
	{
		if (s[i]!='0') { k++; d=0; }
		else
		{
			if (!d) { d=1; p=p*10+k; k=0; }
			else { d=0; p=p*10; }
		}
	}
	if (k) p=p*10+k;
 	cout<<p;
}

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

int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    int i=0;
    int num = 0;
    while(i<s.length()){
        int cnt = 0;
        int flag = 0;
        if(s[i]=='0'){
            if(s[i+1]=='1')
                i++;
            else{
                i+=2;
                num*=10;
            }
            continue;
        }
        while(i<s.length() && s[i]=='1'){
            cnt++;
            flag = 1;
            i++;
        }
        num = num*10+cnt;
    }
    cout<<num;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM INT_MAX
#define mod 1000000007
#define FOR(i,n)    for(int i=0;i<n;i++)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

struct Apple{
    ll cor;
    ll value;
}app[100];

bool cmp(Apple a,Apple b)
{
    return (a.cor < b.cor);
}

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

int main(){
    ll n;
    cin>>n;
    char s[n];
    for(ll i=0;i<n;i++){
        cin>>s[i];
    }

    ll one = 0,zero = 0;
    for(ll i=0;i<n;i++){
        if(s[i]=='1'){
            one++;
            if(zero>1){
                zero-=1;
                while(zero--){
                    cout<<0;
                }
            }
            zero = 0;
            if(i==n-1){
                cout<<one;
            }
        }
        else if(s[i]=='0'){
            zero++;
            if(one!=0)
                cout<<one;
            one = 0;
            if(i==n-1){
                if(zero>1){
                    zero-=1;
                    while(zero--){
                        cout<<0;
                    }
                }
            }
        }
    }
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        cin>>s;
        int num=0;
        int tem=0;
        int sum=0;
        int flag=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]=='1')
            {
                if(tem>1) printf("0");
                num++;
                tem=0;
            }
            else
            {
                if(num) printf("%d",num);
                tem++;
                num=0;
            }
            if(i==n-1)
            {
                if(num)
                {
                    printf("%d",num);
                }
            }
        }
        for(int i=n-1;;i--)
        {
            if(s[i]=='0') printf("0");
            else break;
        }
        puts("");
    }
    return 0;
}

/*
   author: rishi_mohan
   created_at: Tue 24 Nov 2020 10:35 AM
*/
#include<bits/stdc++.h>
using namespace std;

#define    ll            long long
#define    rep(i,a,b)    for(int i=a; i<b; i++)
#define    all(x)        (x).begin(),(x).end()

void Solve(){
    int n; cin >> n;
    string s; cin >> s;
    string ans; int c = 0;
    for(int i=0; i<n; i++){
        if(s[i] == '1') c++;
        else{
            if(c!=0) {ans += (c+'0');
            c=0;}
        }
    }
    if(c!=0) ans += (c+'0');
    cout << ans << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);  int t = 1;
	//cin >> t;
	while(t--) Solve();
}

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

void main()
{
	int x,count=0;
	cin>>x;
	string val ;
	cin>>val;
	for(int i=0;i<x;++i)
	{
		if(val[i]=='0')
	    {
				cout<<count;
				count=0;
		}
		else
			++count;
	}

	if(count!=0)
		cout<<count<<endl;
}

#include <bits/stdc++.h>

using namespace std;

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

  string bin_num;
  cin >> bin_num;

  string encoded_num = "";

  for(int i = 0; i < bin_num.size(); i++){
    int cnt(0);
    int k(i);
    int cnt_zero(0);
    /*
    while(bin_num[k] == '0'){
      cnt_zero++
      k++;
    }
    while(cnt_zero >= 2){
      encoded_num += '0';
      cnt_zero -= 2;
    }
    */
    while(bin_num[k] != '0' && k < bin_num.size()) k++, cnt++;
    if(cnt > 0) encoded_num += char(cnt + '0');
    k++;
    if(bin_num[k] == '0') encoded_num += '0', i = k;
    else i = k - 1;
  }
  cout << encoded_num << "\n";

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
# define ll long long int
int main()
{

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<string> ans;
    int cnt=0,zcnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            if(zcnt>0){
                for(int i=0;i<zcnt;i++) ans.push_back("0");
            zcnt=0;
            }
            cnt++;
        }
        else if(s[i]=='0' && s[i-1]=='1'){
            ans.push_back(to_string(cnt));
            cnt=0;
        }
        else zcnt++;

    }
    if(cnt!=0) ans.push_back(to_string(cnt));
    for(int i=0;i<zcnt;i++) ans.push_back("0");
    for(int i=0;i<ans.size();i++) cout<<ans[i];
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    string s;cin>>s;
    int p=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')p++;
        else {
            cout<<p;
            p=0;
        }
    }
    return 0;
}

#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main(){
long long l,i,c=0,p=0,prev=0;
string s,n;
cin>>l;
cin>>n;

    for(i=0;i<l;i++){
        if(n[i]=='1'){
            if(p==-1){
                p=0;
            }
            p++;
        }
        else{
            if(c==0){
                if(p!=-1){
                stringstream ss;
                ss << p;
                string str = ss.str();
                s=s+str;
                c++;
                p=0;
                }
                else{
                    p=0;
                }
            }
            else{
                s=s+"0";
                c=0;
                p=-1;
            }

        }
    }
stringstream ss;
                ss << p;
                string str = ss.str();
                s=s+str;
    cout<<s;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,count1=0;
    cin>>n;
    char c[100006];
    cin>>c;
    int p=0;
    for(int i=0;i<n;i++)
    {
        while(c[i]=='1' && i<n)
        {
            ++count1;
            ++i;
        }
        if(p!=(i-1))
        {
            cout<<count1;
            if(count1==0)
                p=i;
        }
        count1=0;
    }
}

#include<stdio.h>
#include<string.h>
int main()
{
	int n,i;
    char a[100];
	while(scanf("%d",&n)!=EOF)
	{
		int sum=0;int num=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]==1)
			sum++;
			else
			{
				printf("%d",sum);
				sum=0;
				num=1;
			}
		}
		if(sum!=0)
		printf("%d\n",sum);

}
}

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

int main() {
	ios::sync_with_stdio(false);
	int tmp;
	cin >> tmp;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		int sum = 0;
		for (int j = i; j < s.length(); j++) {
			sum += s[j] - '0';
			if (s[j] == '0') {
				break;
			}
			i++;
		}
		cout << sum;
	}
	cout << endl;
	return 0;
}

#include<cstdio>
#include<memory.h>
#include<cstdlib>
#include<iostream>
using namespace std;

int main()
{
	int s = 0,j=0,n=0;
	bool flag =false;
	scanf("%d",&s);
	char in[1000000],out[10000];
	scanf("%s",&in);
	for(int i=0;i<s;i++)
	{
		if(in[i]=='1')
		{
			n++;
			flag = true;
		}
		else if(in[i]=='0'&&flag==true)flag = false;
//		else if(in[i]=='0'&&in[i+1]=='1')flag=false;
		else if(in[i]=='0')flag = true;
		if(flag == false&& i!=s-1)
		{
			out[j++] = n + '0';
			n = 0;
			flag = true;
		}
		else if(i==s-1&&in[i]=='0')
		{
			out[j++] = n+'0';
			out[j++] = n+'0';
		}
		else if(i==s-1)
		{
			out[j++] = n+'0';
		}

	}
	printf("%s\n",out);
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

#define DEBUG	0
#define MAX_N	100

int N;

int solve()
{

	return 0;
}

int main()
{
	if (DEBUG) freopen("input.txt", "r", stdin);

	char num;
	int cnt = 0;

	scanf("%d%*c", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%c", &num);

		if (num == '1')
			cnt++;
		else
		{
			printf("%d", cnt);
			cnt = 0;
		}
	}
	if (num == '1' && cnt > 0)
		printf("%d", cnt);
	printf("\n");

	return 0;
}

#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	char c;
	for(int i=0; i<n; i++){
		int num = 0;
		cin >> c;
		while(c!='0' && i<n){ num++; cin >> c; i++;}
		cout << num;
		num = 0;
	}
	return 0;
}

#include <iostream>
#include <cstring>
using namespace std;
int n;
char s[100];
int main()
{
	cin >> n >> s;
	int i, l = strlen(s);
	for (i = 0; i < l; i++)
	{
		int q = 0;
		bool flag = false;
		while (s[i] == '1' && i < l)
		{
			q++;
			i++;
			flag = true;
		}
		if (flag)
			cout << q;
		else
			cout << s[i];
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int const mod = 1e9 + 7;
int const N = 1e5;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	string res = "";
	for (int i = 0; i < n; i++){
		int cnt = 0;
		while (s[i] == '1') cnt++, i++;
		if (cnt)
			res += to_string(cnt);
		else if (i == 0) continue;
		else if (s[i - 1] == '0') res += '0';
	}int i = 0;
	while (res[i] == '0') i++;
	for (; i < res.size(); i++) cout << res[i];
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        int j = i + 1;
        while (j < n && s[j] == s[i])
            ++j;
        if (s[i] == '0') {
            if ((j - i) > 1) {
                int temp = (j - i - 1);
                if (j == n)
                    temp = j - i;
                while ( temp-- ) {
                    cout << 0;
                }
            }
        }
        else {
            cout << (j - i);
        }
        i = j - 1;
    }
    return 0;
}

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

int main()
{
    ll i,j,n,t,mx=0,cnt=0,c=0,mn=1e18;
    string s;
    bool f=0,flag=0;
    cin>>n;
    cin>>s;

    for(i=0; i<n; i++)
    {
        if(s[i]=='0')
        {
            cout<<cnt;
            cnt=0;f=0;c++;
            for(j=i+1;j<n;j++)
            {
                if(s[j]=='0')
                    c++,i=j;
                else
                {
                    i=j-1;flag=1;
                    for(j=1;j<=c/2;j++)
                        cout<<0;
                        c=0;
                    break;
                }
            }
            if(!flag)
            {
                for(j=1;j<=c/2;j++)
                        cout<<0;
            }
        }
        else
            cnt++,f=1;

    }
    if(f)
        cout<<cnt<<endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll             long long
#define sc1(a)         scanf("%d",&a)
#define llsc1(a)       scanf("%lld",&a)
#define sc2(a,b)       scanf("%d %d",&a,&b)
#define llsc2(a,b)     scanf("%lld %lld",&a,&b)
#define sc3(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define llsc3(a,b,c)   scanf("%lld %lld %lld",&a,&b,&c)
#define pf             printf
#define cpfl(s)        cout<<s<<endl
#define cpf(s)         cout<<s
#define FOR(a)         for(int i=0;i<a;i++)
#define inf            2e9
#define pr             pair<int,int>
#define newline        printf("\n")
#define mem(a,b)       memset(a,b,sizeof(a))
#define srt(a,n)       sort(a,a+n)
#define mx             5700
#define mm             1420
#define mod            1000000
int main()
    {
        int n,cnt,j;
        string s;
        sc1(n);
        cin>>s;
        for(int i=0;i<n;i++){
            cnt=0;
            if(s[i]=='1'){
                cnt=1;
                for(j=i+1;j<s.length();j++){
                    if(s[j]!='1')break;
                    cnt++;
                }
                pf("%d",cnt);
                i=j;
            }
            else if(s[i]=='0')pf("0");
        }
        newline;
        return 0;
    }

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	string s;
	int n;
	while (cin >> n)
	{
		cin >> s;
		int cnt=0,flag=0;
		for (int i = 0; i < s.length(); i++)
		{
			if (s[i] == '1')
				cnt++;
			else if (s[i] == '0' && !flag)
			{
				cout << cnt;
				cnt = 0;
				flag = 1;
			}
			else if (i < s.length() - 1)
			{
				cout << cnt;
				cnt = 0;
			}
		}
		cout << cnt << endl;;
	}
	return 0;
}

#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>

#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define EPS 0.000001
#define INF 1000000000

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define ABC(a) (((a) > 0) ? (a) : (-(a)))
#define LOOP(i, n) for (int ((i) = 0); ((i) < (n)); ((i)++))

typedef long long int lint;

using namespace std;

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

	int answer = 0;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == '1')
			answer++;
		else
		{
			printf("%d", answer);
			answer = 0;
		}
	}

	if (answer != 0)
		printf("%d", answer);

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string  s;
	cin >> s;
	if (n == 1 && s == "0") {
		cout << 0;
		return 0;
	}
	int ans = 0, tmp = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1') {
			tmp += 1;
		} else {
			if (tmp) {
				ans *= 10;
				ans += tmp;
				tmp = 0;
			}
			if (i == 0 || s[i - 1] == '0') {
				ans *= 10;
				i++;
			}
		}
	}
	if (tmp) {
		ans *= 10;
		ans += tmp;
	}
	cout << ans << '\n';
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char st[100];
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    scanf("%s",st);
    int cou;
    for(int i=0;i<n;i++)
    {
        cou=0;
        if(st[i]=='0')
        {
            ans*=10;
            while(st[i]=='0')
            {
                i++;
            }
            i--;
            continue;
        }
        while(st[i]=='1')
        {
            cou++;
            i++;
        }
        ans=ans*10+cou;

        if(i>=n)break;
    }
    printf("%d\n",ans);
}

#include "bits/stdc++.h"

using namespace std;

int main()
{
	string s;   long long  e=0,b,i,a,s1[100],e1,t=0,j=0;
	cin>>a;
	cin>>s;
	for(i=0;i<a;i++)if(s[i]=='1')e++;
	e1=a-e;
	if(a==e)cout<<e<<endl;
	else
	{
	  for(i=0;i<a;i++)if(s[i]=='0'){s1[j]=i-t;t=i;j++;}

	cout<<s1[0];
     for(i=1;i<j;i++)cout<<s1[i]-1;
     if(s[a-1]=='1')cout<<1<<endl;
}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
vector <int> ans;
string as = "";
char p[2], b;
int a = 0,n;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b;
		if (b == '1')
		{
			a++;
			if (i == n - 1) ans.push_back(a);
		}
		else
		{
			ans.push_back(a);
			a = 0;
		}
	}
	for (int i = 0; i < ans.size(); i++)
	{
		sprintf(p, "%d", ans[i]);
		as += p;
	}
	cout << as;
	return 0;
}

#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string ans = "", s;
	int n, cnt, i;
	cin >> n >> s;
	for (i = 0; i < n; i++){
        if (s[i] == '1'){
            cnt = 0;
            while (i < n && s[i] == '1'){
                cnt++;
                i++;
            }
            cout << cnt;
        }
        else{
            cout << 0;
        }
	}
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n,a=0,d=0;
    bool b=false,c=false;
    string s;
    cin >> n >> s;
    string ans="";
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            if(c)
            {
                for(int i=0;i<d;i++)
                    ans+='0';
                d=0;
                b=false;
                c=false;
            }
            a++;
        }
        if(s[i]=='0')
        {
            if(i==n-1)
               for(int i=0;i<d+2;i++)
                    ans+='0';
            if(!b)
            {
               ans+='0'+a;
               a=0;
               d=0;
               b=true;
               continue;
            }
            if(b)
            {
                c=true;
                d++;
            }
        }
    }
    if(a>0)
        ans+='0'+a;
    cout << ans;
}

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

int main()
{
    int n, cnt = 0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        {
            if(s[i]=='1')
                cnt++;
            else
            {
                if(s[i-1]=='0')
                    printf("0");
                else
                {
                    printf("%d", cnt);
                    cnt = 0;
                }
            }
        }
        if(cnt!=0)
            printf("%d", cnt);
}

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define pb(x) push_back(x)
#define F(i, n) for (int i = 0; i < n; i++)
#define F1(i, n) for (int i = 1; i <= n; i++)
#define all(x) x.begin(), x.end()
#define geti1(x) scanf("%d", &x)
#define geti2(x, y) scanf("%d%d", &x, &y)
#define geti3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
// clang-format off
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)
// clang-format on

#define ABS(x) (((x) > 0) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ((x) > (y) ? ((x) > (z) ? (x) : (z)) : ((y) > (z) ? (y) : (z)))
#define MIN3(x, y, z) ((x) < (y) ? ((x) < (z) ? (x) : (z)) : ((y) < (z) ? (y) : (z)))
#define MID3(val1, val2, val3) MAX2(MIN2(MAX2(val1, val2), val3), MIN2(val1, val2))

#define INF 2147483647
#define IINF 9123456789123456789
#define M_PI 3.14159265358979323846
//--------------------------------------------------//
int main() {
    int N;
    geti(N);
    string s;
    cin >> s;
    int ans = 0;
    int pv = 0;
    while (pv < s.size()) {
        if (s[pv] == '1') {
            int cnt = 0;
            while (s[pv] == '1' && pv < s.size()) pv++, cnt++;
            ans = ans * 10 + cnt;
        } else if (s[pv] == '0') {
            int cnt = 0;
            while (s[pv] == '0' && pv < s.size()) pv++, cnt++;
            F(i, cnt / 2) {
                ans *= 10;
            }
        }
    }
    cout << ans;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    string s;cin>>s;
    int p=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')p++;
        else {
            cout<<p;
            p=0;
        }
    }
    return 0;
}

/*If I get TLE , it is good.If I get AC,it's NICE !*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const int MAXN=1e7+10;
const ll mod=1e9+7;
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
char str[200];
int main(void)
{
    int n;
    cin >> n;
    cin >> str;
    int sum=0;
    int cnt=0;
    for(int i=0;i<=n-1;i++)
    {
        if(str[i]=='1')
        {
            if(cnt>=2)
            {
                for(int i=1;i<=cnt-1;i++)
                    cout << "0";
                cnt=0;
            }
            sum+=str[i]-'0';
        }
        else if(str[i]=='0')
        {
            cnt++;
            if(sum)
            {
                cout << sum;
                sum=0;
            }
        }
    }
    if(sum) cout << sum << endl;
    else    cout<<endl;
}
/*unsigned   int   0～4294967295
int   -2147483648～2147483647
unsigned long 0～4294967295
long   -2147483648～2147483647
long long的最大值：9223372036854775807
long long的最小值：-9223372036854775808
unsigned long long的最大值：1844674407370955161*/
//s.erase(remove(s.begin(),s.end(),' '),s.end());读入不确定字符长度，同时去空格

/*
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=95;
int digit[20];
int main(void){
    char str[N];
    int n;
    while(~scanf("%d",&n)){
        int t=0;
        scanf("%s",str);
        memset(digit,0,sizeof(digit));
        int len=strlen(str);
        for(int i=0;i<=len/2;i++){
            char c;
            c=str[i];
            str[i]=str[len-1-i];
            str[len-1-i]=c;
        }
        for(int i=0;i<len;){
            if(str[i]=='1'){
                while(str[i]=='1') digit[t]++,i++;
                t++;
            }
            if(str[i]=='0'){
                if(i==0) digit[]
                i++;
                if(str[i]=='0'){
                    digit[t++]=0;
                    i++;
                }
            }
        }
        for(int i=t-1;i>=0;i--){
            printf("%d",digit[i]);
        }
        if(len==1 && str[0]=='0') printf("0");
        puts("");

    }
    return 0;
}

*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
    char s[100];
    int n;
    int a[50];
    while(~scanf("%d",&n)){
        scanf("%s",s);
        int t=0;
        int len=strlen(s);
        bool flag=true;
        memset(a,0,sizeof(a));
        for(int i=0;i<len;i++){
            if(s[i]=='1'){
                while(s[i]=='1') a[t]++,i++;
                i--;
                t++;
            }
            else if(s[i]=='0'){
                if(flag){
                    flag=false;
                }
                else{
                    flag=true;
                    a[t++]=0;
                }
            }
        }
        for(int i=0;i<t;i++){
            printf("%d",a[i]);
        }
        puts("");
    }

    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,c=0,aux=0,b=0,con=0;
    string x;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        if(x[i]=='1'){c++;con=0;}
        else{
            con++;
            if(con!=1){
                con=0;
                cout<<0;
            }
            else{
                cout<<c;
                c=0;
            }

        }

    }
    if(c)cout<<c;
    return 0;
}

#include <iostream>
using namespace std;
#define ll long long int
int main() {
	// your code goes here

	ll n;
	cin>>n;
	int count=0;
	string s;
	cin>>s;
	ll val=0;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')
			count++;
		else
		{
			val = val*10+count;
			count=0;
		}
	}
	if(s[n-1]=='1')
		val = val*10+count;

	cout<<val;
	return 0;
}

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

#define ll long long
#define sz 105

using namespace std;

int main()
{
    char str[sz];
    ll n;

    scanf("%lld %s",&n,str);

    ll cnt0=0,cnt1=0,sum=0;

    for(ll i=0; i<n; i++)
    {
        if(str[i]=='0')
        {
            cnt0++;

            if(cnt1>0)
                sum=(sum*10)+cnt1;

            cnt1=0;
        }

        else
        {
            cnt1++;

            if(cnt0>1)
                sum=sum*10;

            cnt0=0;
        }
    }

    if(cnt1>0)
        sum=(sum*10)+cnt1;

    if(cnt0>1)
        sum=sum*10;

    printf("%lld\n",sum);

    return (0);
}

#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
using namespace std;
char a[100];
int main()
{
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
        int c1=0,c0=0,flag=1;
    for(i=1;i<=n;i++)
    {
        if(a[i]=='1')
        {
            c1++;
        }
        if(a[i]=='0')
        {
            c0++;
        }
        if(a[i-1]=='0'&&a[i]=='1')
        {
            if(c0>1)
                cout<<0;
            c0=0;
        }
        if(a[i-1]=='1'&&a[i]=='0')
        {
            cout<<c1;
            c1=0;
        }
    }
    if(a[n]=='1')
        cout<<c1;
    else
    {
        if(c0>1)
        cout<<c0;
    }
    cout<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    long long l=0;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        char ch;cin>>ch;
        if(ch=='0')
        {
            l=l*10+cnt;
            cnt=0;
        }
        else
        {
            cnt++;
        }
    }
    if(cnt!=0){l=l*10+cnt;cnt=0; }
    //for(int i=0;i<j;i++)
        cout<<l;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mem(a,t) memset(a,t,sizeof(a))
#define pb push_back
#define mp make_pair
#define N 100005
#define M 200005
#define LL long long
const int inf=1e9;

int main()
{
    int n,flag,cnt;
    string str;
    cin>>n;
    cin>>str;
    flag=0;
    cnt=0;
    rep(i,0,str.length()){
        if(str[i]=='0'){
            if(cnt){
                cout<<cnt;
                cnt=0;
                flag=1;
            }
            else{
                cout<<0;
            }
        }
        else{
            ++cnt;
            flag=0;
        }
    }
    if(cnt) cout<<cnt;
    cout<<endl;
    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
char str[100];
int n,m;
int main (){
	while(~scanf("%d",&n)){
		scanf("%s",str);
		int cnt = 1,len = strlen(str);
		for(int i=1;i<len;i++){
			if(str[i]=='0'&&str[i-1]=='0'){
				putchar('0');
			}
			else if(str[i]=='0'){
				printf("%d",cnt);
				cnt = 0;
			}
			else cnt++;
		}
		if(cnt) printf("%d",cnt);
		puts("");
	}
}

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

#define ll long long
#define sz 105

using namespace std;

int main()
{
    char str[sz];
    ll n;

    scanf("%lld %s",&n,str);

    ll cnt0=0,cnt1=0,sum=0;

    for(ll i=0; i<n; i++)
    {
        if(str[i]=='0')
        {
            cnt0++;

            if(cnt1>0)
                sum=(sum*10)+cnt1;

            cnt1=0;
        }

        else
        {
            cnt1++;

            if(cnt0>1)
            {
                for(ll j=1; j<cnt0; j++)
                    sum=sum*10;
            }

            cnt0=0;
        }
    }

    if(cnt1>0)
        sum=(sum*10)+cnt1;

    if(cnt0>1)
    {
        for(ll j=1; j<cnt0; j++)
            sum=sum*10;
    }

    printf("%lld\n",sum);

    return (0);
}

#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int num;
	vector<int> ans;
	int i=0;
	int flag = 0;
	while(i<n){
		num = 0;
		if(s[i]=='1'){
			flag=0;
			while(s[i]=='1'){
				num++;
				i++;
			//flag=1;
			}
			cout<<num;
		}
		else{
			flag++;
			if(flag%2==0)
				cout<<num;
		}
	//	cout<<num;
		i++;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1 << 30;
int n;
char s[95];

int main()
{
    while(~scanf("%d", &n))
    {
        scanf("%s", s);
        int j, sum;
        for(int i = 0; i < n; i++)
        {
            if(s[i] == '1')
            {
//                printf("%c\n", s[i]);
                sum = 0;
                for(j = i; j < n; j++)
                {
                    if(s[j] == '0')
                        break;
                    sum++;
                }
                i = j - 1;
                printf("%d", sum);
            }
            else
            {
                sum = 0;
                for(j = i; j < n; j++)
                {
                    if(s[j] == '1')
                        break;
                    sum++;
                }
                i = j - 1;
                for(int j = 0; j < sum / 2; j++)
//                if(sum > 1)
                    printf("0");
            }
        }
        puts("");
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,l=0;
    bool b=false;
    cin>>n;
    string s;
    cin>>s;
    for (int i=0;i<s.size();++i)
    {
        if (s[i]=='1' && s[i+1]=='0'){cout<<l+1;l=0;i+=1;}
        else if (s[i]=='1' && s[i+1]!=0)++l;
        else if (s[i]=='0'){cout<<0;}
    }
    if (l+1>0)cout<<l+1;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char s[200];
pair<int,int>a[200];

int main(){
	int n;
	cin >> n;
	cin >> s + 1;
	int head = 1,all = 0;
	for(int i = 1;i <= n;i++){
		if(s[i] != s[i + 1]){
			if(s[i] == '1'){
				a[++all].first = i - head + 1;
				a[all].second = 1;
				head = i + 1;
			}
			else{
				a[++all].first = i - head + 1;
				a[all].second = 0;
				head = i + 1;
			}
		}
	}
	for(int i = 1;i <= all;i++){
		if(a[i].second == 1){
			cout << a[i].first;
		}
		else{
			if(i == all){
				for(int j = 1;j <= a[i].first;j++){
					cout << '0';
				}
			}
			else{
				if(a[i].first > 1) cout << '0';
			}
		}
	}
}

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int LL;
#define fi first
#define se second
#define pb push_back
const int N = 2005;

int main(){
// ios::sync_with_stdio(false);
int n;
string s; cin>>n>>s;
bool f = true;
int cnt  = 0;
std::vector<int> v;
for(auto c : s){
	if(c == '1')cnt++;
	else if(c == '0'){v.pb(cnt); cnt = 0;}
}
if(s[(int)s.length() - 1] == '1')v.pb(cnt);
for(auto x : v)cout << x;
}

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

#define ll long long
#define ull unsigned long long
#define st size_t
#define quick ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair

int main() {
  quick;
  int n;
  string str;
  cin >> n >> str;
  char prev = '\0';
  ll ans = 0;
  string res = "";
  for (char c : str) {
    if (prev == '\0') {
      prev = c;
      ans = 1;
    }
    else if (prev == c) {
      ans++;
    } else {
      if (prev == '1')
	res += to_string(ans);
      else
	if (ans > 1)
	  res += '0';
      ans = 1;
      prev = c;
    }
  }
  if (prev == '1')
    res += to_string(ans);
  else
    if (ans > 1)
      res += '0';
  cout << res << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long>   vll;
typedef vector<pair<int,int> >   vii;
#define pb push_back
#define mp  make_pair
#define ll long long
#define ff first
#define ss second
#define prique priority_queue
int inf = 1E9;

int main(){

	int n;
	cin >> n;
	string ans;
	char c;
	string s;
	cin >> s;

	int nz = 0;
	for (int i = 0; i < n; ++i)
	{
		c = s[i];
		if(c == '1'){
			nz++;
			if(nz == 10)
			{
				ans += '9';
				nz = 1;
			}
		}
		else
		{
			ans += to_string(nz);
			nz = 0;
		}
	}

	if(nz)
		ans += to_string(nz);

	cout << ans << '\n';
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
char a[100];
int main()
{
    int n;
    cin>>n;
    cin>>a;
    int b[15];
    int ans=1,pos=0;
    mem(b);
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i-1]) ans++;
        else
        {
            b[pos++]=ans;
            ans=1;
        }
    }
    b[pos++]=ans;
    for(int i=0;i<pos;i++)
    {
        if(i%2==0) cout<<b[i];
        else
        {
            if(b[i]==1) continue;
            else cout<<'0';
        }
    }
    cout<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{   int n,test1=0,test0=0;
string s;
    cin>>n;
    cin>>s;
    cout<<s<<endl;
for (int i=0;i<n;i++){
if (s[i]==s[0]){
test0=0;
test1++;
}
else {
test0++;}

if ((test0==1  || i==n-1) && test1>0) {cout<<test1;test1=0;}
if(test0>1){cout<<"0";}
if ((test0>=1) && i==n-1){cout<<"0";}

}
return 0;

}

#include<bits/stdc++.h>
using namespace std;
int n;string s;long long int cnt1,cnt0;
int main()
{
   cin>>n;cin>>s;
   for(int i=0;i<n;i++)
   {
       if(i==n-1)
       {
           if(s[i]=='1')
           {
               cout<<cnt1+1;
           }
           else
           {
               if(s[i-1]=='0')
                cout<<0;
           }
       }
       if(s[i]=='1')
       {
           cnt1++;
       }
       else if(s[i]=='0')
       {
           if(i-1>=0&&s[i-1]=='0')
           {
               cout<<0;
           }
           else
           {
               cout<<cnt1;
               cnt1=0;
           }
       }
   }
   cout<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int n,js;
char s[1000000];
int main()
{
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(i==n-1)
        {
            cout<<js+1;
            return 0;
        }
        if(s[i]=='1')js++;
        if(s[i]=='0'&&s[i-1]!='0')cout<<js,js=0;
        if(s[i]=='1'&&s[i-1]=='0')cout<<0;
    }
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
char str[95];
int main(){
	int n;
	LL ans;
	while(~scanf("%d",&n)){
		ans=0;
		scanf("%s",str);
		int j=n-1;
		while(str[j]!='1'&&j>=0){
			j--;
		}
		for(int i=0;i<=j;){
			if(str[i]=='1'){
				int cnt=0;
				while(str[i]=='1'&&i<=j){
					cnt++;
					i++;
				}
				ans *= 10;
				ans += cnt;
			}
			else if(str[i]=='0'){
				int cnt=0;
				while(str[i]=='0'&&i<=j){
					cnt++;
					i++;
				}
				if(cnt>1) ans *= 10;
			}
		}
		if(str[n-1]!='1') ans *= 10;
		printf("%I64d\n",ans);
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,f = 1;
    char a[100];
    scanf("%d %s", &n, a);
    for(int i =0 ; a[i]; i++)
    {
        if(a[i] == '1')
        {
            c++;
        }
        else
        {
            if(f)
            {
                printf("%d", c);
                c = 0;
                f = 0;
            }
            else
                f = 1;
        }
    }
    if(!f)
    {
        printf("%d", c);
    }
    return 0;
}

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

int main(){
    int n,zeros=0;
    string st;
    cin>>n>>st;
    int c=0,num=0;
    for(int a_i=0;a_i<n;a_i++){
        if(st.at(a_i)=='1'){
            c++;
            zeros=0;
        }
       if(st.at(a_i)=='0'||a_i==n-1){
            zeros++;
            if(zeros==1&&c>0||a_i==n-1){
            num=10*num+c;
            c=0;
            }
            else if(c==0&&zeros==2){
                num=10*num+c;
                c=0;
                zeros=0;
            }

        }
    }
    cout<<num<<endl;
}

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>    // std::sort
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, i;
	string s, output;
	cin >> n >> s;
	//cout  << n << "\n";
	//cout <<s << "\n";

	int count = 0;
	for(i =0; i < s.length(); i++)
	{
		if(s[i] == '0')
		{
			count = 0;
			output += std::to_string(count);

		}

		else
			count ++;
	}

	cout << output << endl;
	return 0;

}