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

struct data{
    int ch;
    int am;
};

string s,t;
int as[26], at[26], nw[26];
int siz;

int main(){

    cout<<"hello\n";
    /*cin>>s>>t;
    //scanf("%s %s", s, t);
    siz = s.size();
    int tot = 0;

    for( int i = 0; i < siz; i++ ){
        as[ s[i]-'A' ]++;  at[ t[i]-'A' ]++;
    }
    queue<data> q;
    for( int i = 0; i < 26; i++ ){
        if( as[i] < at[i] ){
            data d;
            d.ch = i; d.am = at[i] - as[i];  tot += d.am;
            q.push( d );
        }
    }
    */
    int ind = 0;
    /*while( !q.empty() ){
        //cout<<q.size()<<endl;
        data d = q.front();  q.pop();
        while( d.am != 0 ){
            int tm = ind;
            ind++;
            int who = s[ tm ] - 'A';
            if( as[who] <= at[who] ) continue;
            if( who > d.ch ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else if( at[who] == nw[who] ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else nw[ who ]++;
        }
    }*/
    //cout<<"hello\n";
    //cout<<tot<<endl;
    cout<<"ABC"<<endl;
    //printf("\n%s\n", s);
    return 0;
}


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

struct data{
    int ch;
    int am;
};

char s[100004], t[100004];
int as[26], at[26], nw[26];
int siz;

int main(){

    scanf("%s %s", s, t);
    siz = strlen(s);
    int tot = 0;

    for( int i = 0; i < siz; i++ ){
        as[ s[i]-'A' ]++;  at[ t[i]-'A' ]++;
    }
    queue<data> q;
    for( int i = 0; i < 26; i++ ){
        if( as[i] < at[i] ){
            data d;
            d.ch = i; d.am = at[i] - as[i];  tot += d.am;
            q.push( d );
        }
    }

    int ind = 0;
    while( !q.empty() ){
        //cout<<q.size()<<endl;
        data d = q.front();  q.pop();
        while( d.am != 0 ){
            int tm = ind;
            ind++;
            int who = s[ tm ] - 'A';
            if( as[who] <= at[who] ) continue;
            if( who > d.ch ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else if( at[who] == nw[who] ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else nw[ who ]++;
        }
    }
    cout<<tot;
    printf("\n%s\n", s);
    return 0;
}


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

struct data{
    int ch;
    int am;
};

char s[100004], t[100004];
int as[26], at[26], nw[26];
int siz;

int main(){

    scanf("%s %s", s, t);
    siz = strlen(s);
    int tot = 0;

    for( int i = 0; i < siz; i++ ){
        as[ s[i]-'A' ]++;  at[ t[i]-'A' ]++;
    }
    queue<data> q;
    for( int i = 0; i < 26; i++ ){
        if( as[i] < at[i] ){
            data d;
            d.ch = i; d.am = at[i] - as[i];  tot += d.am;
            q.push( d );
        }
    }

    int ind = 0;
    while( !q.empty() ){
        //cout<<q.size()<<endl;
        data d = q.front();  q.pop();
        while( d.am != 0 ){
            int tm = ind;
            ind++;
            int who = s[ tm ] - 'A';
            if( as[who] <= at[who] ) continue;
            if( who > d.ch ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else if( at[who] == nw[who] ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else nw[ who ]++;
        }
    }
    cout<<"hello\n";
    cout<<tot;
    printf("\n%s\n", s);
    return 0;
}


#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
#include <fstream>
using namespace std;

struct data{
    int ch;
    int am;
};

string s,t;
int as[26], at[26], nw[26];
int siz;

int main(){

    ifstream fin("input.txt");
    ofstream fout("output.txt");
    //cout<<"hello\n";
    fin>>s>>t;
    //scanf("%s %s", s, t);
    siz = s.size();
    int tot = 0;

    for( int i = 0; i < siz; i++ ){
        as[ s[i]-'A' ]++;  at[ t[i]-'A' ]++;
    }
    queue<data> q;
    for( int i = 0; i < 26; i++ ){
        if( as[i] < at[i] ){
            data d;
            d.ch = i; d.am = at[i] - as[i];  tot += d.am;
            q.push( d );
        }
    }

    int ind = 0;
    while( !q.empty() ){
        //cout<<q.size()<<endl;
        data d = q.front();  q.pop();
        while( d.am != 0 ){
            int tm = ind;
            ind++;
            int who = s[ tm ] - 'A';
            if( as[who] <= at[who] ) continue;
            if( who > d.ch ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else if( at[who] == nw[who] ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else nw[ who ]++;
        }
    }
    //cout<<"hello\n";
    fout<<tot<<endl;
    //cout<<"ABC"<<endl;
    fout<<s<<endl;
    //printf("\n%s\n", s);
    return 0;
}


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

struct data{
    int ch;
    int am;
};

char s[100004], t[100004];
int as[26], at[26], nw[26];
int siz;

int main(){

    scanf("%s %s", s, t);
    siz = strlen(s);
    int tot = 0;

    for( int i = 0; i < siz; i++ ){
        as[ s[i]-'A' ]++;  at[ t[i]-'A' ]++;
    }
    queue<data> q;
    for( int i = 0; i < 26; i++ ){
        if( as[i] < at[i] ){
            data d;
            d.ch = i; d.am = at[i] - as[i];  tot += d.am;
            q.push( d );
        }
    }

    int ind = 0;
    /*while( !q.empty() ){
        //cout<<q.size()<<endl;
        data d = q.front();  q.pop();
        while( d.am != 0 ){
            int tm = ind;
            ind++;
            int who = s[ tm ] - 'A';
            if( as[who] <= at[who] ) continue;
            if( who > d.ch ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else if( at[who] == nw[who] ){
                s[ tm ] = d.ch + 'A';
                as[ who ]--;
                d.am--;
            }
            else nw[ who ]++;
        }
    }*/
    cout<<"hello\n";
    cout<<tot<<endl;
    cout<<s<<endl;
    //printf("\n%s\n", s);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28];
int main()
{
//  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
    int i,j,n;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            a[i]=a[i]-b[i];
        //  printf("%d     %d\n",i,a[i]);
        }
        j=0;
        n=0;
        for(i=1;i<=26;i++)
        {
            if(a[i]<0)
            {
               for(;j<s1;j++)
               {
                   if(a[str[j]-64]>0&&i>int(str[j]-64))
                   {
                       break;
                   }
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       a[str[j]-64]--;
                       //printf("%d      %d\n",i,str[i]-64);
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        j=s1-1;
        for(i=26;i>=1;i--)
        {
            if(a[i]<0)
            {
               for(;j>=0;j--)
               {
                  // printf("%d     %c      %d\n",j,str[j],a[str[i]-64]);
                   if(a[str[j]-64]>0)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        printf("%d\n%s\n",n,str);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28];
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,n;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            a[i]=a[i]-b[i];
        //  printf("%d     %d\n",i,a[i]);
        }
        j=0;
        n=0;
        for(i=1;i<=26;i++)
        {
            if(a[i]<0)
            {
               for(;j<s1;j++)
               {
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       break;
                   }
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       a[str[j]-64]--;
                       //printf("%d      %d\n",i,str[i]-64);
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        j=s1-1;
        for(i=26;i>=1;i--)
        {
            if(a[i]<0)
            {
               for(;j>=0;j--)
               {
                   printf("%d     %c      %d\n",j,str[j],a[str[i]-64]);
                   if(a[str[j]-64]>0)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        printf("%d\n%s\n",n,str);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28];
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,n;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            a[i]=a[i]-b[i];
            //printf("%d     %d\n",i,a[i]);
        }
        j=0;
        n=0;
        for(i=1;i<=26;i++)
        {
            if(a[i]<0)
            {
               for(;j<s1;j++)
               {
                  // printf("%d      %d\n",i,str[i]-64);
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        j--;
        for(i=26;i>=0;i--)
        {
            if(a[i]<0)
            {
               for(;j>=0;j--)
               {
                   if(a[str[j]-64]>0)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        printf("%d\n%s\n",n,str);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28];
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,n;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            a[i]=a[i]-b[i];
        //  printf("%d     %d\n",i,a[i]);
        }
        j=0;
        n=0;
        for(i=1;i<=26;i++)
        {
            if(a[i]<0)
            {
               for(;j<s1;j++)
               {
                   if(a[str[j]-64]>0&&i>int(str[j]-64))
                   {
                       break;
                   }
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       a[str[j]-64]--;
                       //printf("%d      %d\n",i,str[i]-64);
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        j=s1-1;
        for(i=26;i>=1;i--)
        {
            if(a[i]<0)
            {
               for(;j>=0;j--)
               {
                  // printf("%d     %c      %d\n",j,str[j],a[str[i]-64]);
                   if(a[str[j]-64]>0)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        printf("%d\n%s\n",n,str);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28],c[28],d[28];
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,p;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        p=0;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        memset(c,0,sizeof(c));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            if(a[i]>b[i])
            {
                c[i]=a[i]-b[i];
                 p+=c[i];
            }
            else
            {
                d[i]=b[i]-a[i];
            }
        }
        for(i=0;i<s;i++)
        {
            if(c[str[i]-64]==0)
                 continue;
            for(j=1;j<=26;j++)
            {
                if(d[j]>0)
                    break;
            }
            if(c[str[i]-64]==a[str[i]-64]||str[i]-64>j)
            {
                c[str[i]-64]--;
                a[str[i]-64]--;
                str[i]=char (j+64);
                d[j]--;
            }
            else
            {
                a[str[i]-64]--;
            }
        }
        j=s1-1;
        printf("%d\n%s\n",p,str);
    }
    return 0;
}

/*dsada*/


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28];
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,n;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            a[i]=a[i]-b[i];
            //printf("%d     %d\n",i,a[i]);
        }
        j=0;
        n=0;
        for(i=1;i<=26;i++)
        {
            if(a[i]<0)
            {
               for(;j<s1;j++)
               {
                   if(a[str[j]-64]>0&&i<str[i]-64)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        j--;
        for(i=26;i>=0;i--)
        {
            if(a[i]<0)
            {
               for(;j>=0;j--)
               {
                   if(a[str[j]-64]>0)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        printf("%d\n%s\n",n,str);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char str1[100010];
char str[100010];
int a[28],b[28];
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,n;
    while(scanf("%s%s",str,str1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        int s1=strlen(str1);
        int s=strlen(str);
        for(i=0;i<s1;i++)
        {
            b[str1[i]-64]++;
        }
        for(i=0;i<s;i++)
        {
            a[str[i]-64]++;
        }
        for(i=1;i<=26;i++)
        {
            a[i]=a[i]-b[i];
        //  printf("%d     %d\n",i,a[i]);
        }
        j=0;
        n=0;
        for(i=1;i<=26;i++)
        {
            if(a[i]<0)
            {
               for(;j<s1;j++)
               {
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       break;
                   }
                   if(a[str[j]-64]>0&&i<int(str[j]-64))
                   {
                       a[str[j]-64]--;
                       //printf("%d      %d\n",i,str[i]-64);
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        j=s1-1;
        for(i=26;i>=1;i--)
        {
            if(a[i]<0)
            {
               for(;j>=0;j--)
               {
                  // printf("%d     %c      %d\n",j,str[j],a[str[i]-64]);
                   if(a[str[j]-64]>0)
                   {
                       a[str[j]-64]--;
                       str[j]=char(i+64);
                       n++;
                       a[i]++;
                   }
                   if(a[i]==0)
                       break;
               }
            }
        }
        printf("%d\n%s\n",n,str);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int a[20],mark[20];
int b[10],n;
void dfs(int m,int ci)
{
    int i;
    if(ci==6)
    {
        for(i=0;i<=5;i++)
        {
            if(i==0)
                printf("%d",b[i]);
            else
                printf(" %d",b[i]);
        }
        printf("\n");
        return ;
    }
    if(n-m<6-ci)
        return ;
    for(i=m+1;i<=n;i++)
    {
        b[ci]=a[i];
        dfs(i,ci+1);
    }
    return ;
}
int main()
{
    freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
    int i,j,k=0;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)
            break;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        if(k!=0)
            printf("\n");
         k++;
        for(i=1;i<=n-5;i++)
        {
            b[0]=a[i];
            mark[1]=0;
            dfs(i,1);
        }
    }
    return 0;
}

/*#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int step[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};
int a[30][30];
int mark[30][30];
struct st
{
    int x,y;
}look[100];
int m,n,z;
void dfs(int x,int y,int ci)
{
    int i;
    if(ci==m*n)
    {
        z=1;
        return ;
    }
    if(z==1)
    {
        return ;
    }
    for(i=0;i<8;i++)
    {
        int xx=x+step[i][0];
        int yy=y+step[i][1];
        if(a[xx][yy]==1||xx<=0||xx>n||yy<=0||yy>m)
            continue;
        a[xx][yy]=1;
        look[ci].x=xx;
        look[ci].y=yy;
        dfs(x+step[i][0],y+step[i][1],ci+1);
        a[xx][yy]=1;
        if(z==1)
            return ;
    }
    return ;
}
int main()
{
    int i,j,t,f;
    scanf("%d",&t);
    f=0;
    while(t--)
    {
        scanf("%d%d",&m,&n);
        printf("Scenario #%d:\n",++f);
        memset(a,0,sizeof(a));
        memset(mark,0,sizeof(mark));
        z=0;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                if(mark[i][j]==1)
                {
                    continue;
                }
                memset(a,0,sizeof(a));
                a[i][j]=1;
                look[0].x=i;
                look[0].y=j;
                dfs(i,j,1);
                if(z==1)
                    break;
            }
            if(z==1)
                break;
        }
        if(z==1)
        {
            for(i=0;i<m*n;i++)
            {
                printf("%c%d",look[i].x+64,look[i].y);
            }
            printf("\n");
        }
        else
        {
            printf("impossible\n");
        }
            printf("\n");
    }
    return 0;
}*/


#include <cstdio>
#include <iostream>

using namespace std;

char A[100005], B[100005];
int C[30], D[30], mide=0, cambios=0, p;

int main()
{
    freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    scanf("%s%s",&A,&B);
    for(int i=0; A[i]!='\0'; i++){
        ++mide;
        ++C[A[i]-'A'];
        ++D[B[i]-'A'];
    }
    for(int i=0; i<26; i++){
        if(C[i]<D[i]){
            for(int e=0; e<mide and C[i]<D[i]; e++){
                if(C[i]<D[i] and C[A[e]-'A']>D[A[e]-'A'] and A[e]-'A'>i){
                    ++cambios;
                    ++C[i];
                    --C[A[e]-'A'];
                    A[e]=i+'A';
                }
            }
            for(int e=mide-1; e>=0 and C[i]<D[i]; e--){
                if(C[i]<D[i] and C[A[e]-'A']>D[A[e]-'A']){
                    ++cambios;
                    ++C[i];
                    --C[A[e]-'A'];
                    A[e]=i+'A';
                }
            }
        }
    }
    printf("%d\n%s\n",cambios,A);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27];
stack<int>vec[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S);
    REP(i,len)scnt[S[i] - 'A']++,vec[S[i]-'A'].push(i);
    REP(i,len)tcnt[T[i] - 'A']++;
    int ans = 0;
    REP(i,len)
    {
        char tmp = S[i] - 'A';
        if(scnt[tmp] > tcnt[tmp])
        {
            //DEBUG(i);
            //printf("%d\n",tmp);
            bool flag = 0;
            REP(j,tmp)
            {
                if(scnt[j] < tcnt[j])
                {
                    flag = 1;
                    ans ++;
                    S[i] = 'A' + j;
                    scnt[tmp] --;
                    scnt[j] ++;
                    break;
                }
            }
            if(!flag)
            FORD(j,25,tmp)
            {
                if(scnt[j] < tcnt[j])
                {
                    ans ++;
                    int tmp1 = vec[tmp].top();
                    //DEBUG(tmp1);
                    vec[tmp].pop();
                    S[tmp1] = 'A' + j;
                    scnt[tmp] --;
                    scnt[j] ++;
                    i--;
                    break;
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27],f[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S),ans = 0;
    REP(i,len)scnt[S[i] - 'A']++;
    REP(i,len)tcnt[T[i] - 'A']++;
    REP(i,26)f[i] = scnt[i] - tcnt[i],ans+=abs(f[i]);
    ans /= 2;
    REP(i,len)
    {
        int x = S[i] - 'A';
        if(f[x]>0)
        {
            int j;
            for(j=0;j<26 && f[j]>=0;j++);
            if(x>j)
            {
                scnt[x] --;scnt[j] ++;
                f[x] --; f[j] ++;
                S[i] = 'A' + j;
            }
            else
            {
                //DEBUG(i);DEBUG(scnt[x]);DEB
                if(scnt[j] > tcnt[j])
                {
                    scnt[x] --;
                }
                else
                {
                    scnt[x] --;scnt[j] ++;
                    f[x] --; f[j] ++;
                    S[i] = 'A' + j;
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27],f[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S);
    REP(i,len)scnt[S[i] - 'A']++;
    REP(i,len)tcnt[T[i] - 'A']++;
    REP(i,26)f[i] = scnt[i] - tcnt[i];
    int ans = 0;
    REP(i,len)
    {
        char tmp = S[i] - 'A';
        if(f[i]>0)
        {
            //DEBUG(i);
            //printf("%d\n",tmp);
            bool flag = 0;
            REP(j,tmp)
            {
                if(f[j]<0)
                {
                    flag = 1;
                    ans ++;
                    S[i] = 'A' + j;
                    scnt[tmp] --;
                    f[tmp] --;
                    scnt[j] ++;
                    f[j] ++;
                    break;
                }
            }
            if(!flag)
            {
                FOR(j,tmp,25)
                {
                    if(f[j]<0)
                    {
                        if(scnt[tmp]>1)
                        {
                            scnt[tmp]--;
                        }
                        else
                        {
                            ans ++;
                            ans ++;
                            S[i] = 'A' + j;
                            scnt[tmp] --;
                            f[tmp] --;
                            scnt[j] ++;
                            f[j] ++;
                        }
                        break;
                    }
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27],f[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S),ans = 0;
    REP(i,len)scnt[S[i] - 'A']++;
    REP(i,len)tcnt[T[i] - 'A']++;
    REP(i,26)f[i] = scnt[i] - tcnt[i],ans+=abs(f[i]);
    ans /= 2;
    REP(i,len)
    {
        int x = S[i] - 'A';
        if(f[x]>0)
        {
            int j;
            for(j=0;j<26 && f[j]>=0;j++);
            if(x>j)
            {
                scnt[x] --;scnt[j] ++;
                f[x] --; f[j] ++;
                S[i] = 'A' + j;
            }
            else
            {
                if(scnt[x] > scnt[j])
                {
                    scnt[x] --;
                }
                else
                {
                    scnt[x] --;scnt[j] ++;
                    f[x] --; f[j] ++;
                    S[i] = 'A' + j;
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27],f[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S),ans = 0;
    REP(i,len)scnt[S[i] - 'A']++;
    REP(i,len)tcnt[T[i] - 'A']++;
    REP(i,26)f[i] = scnt[i] - tcnt[i],ans+=abs(f[i]);
    ans /= 2;
    REP(i,len)
    {
        int x = S[i] - 'A';
        if(f[x]>0)
        {
            int j;
            for(j=0;j<26 && f[j]>=0;j++);
            if(x<j)
            {
                scnt[x] --;scnt[j] ++;
                f[x] --; f[j] ++;
                S[i] = 'A' + j;
            }
            else
            {
                if(scnt[x] > scnt[j])
                {
                    scnt[x] --;
                }
                else
                {
                    scnt[x] --;scnt[j] ++;
                    f[x] --; f[j] ++;
                    S[i] = 'A' + j;
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27],f[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S),ans = 0;
    REP(i,len)scnt[S[i] - 'A']++;
    REP(i,len)tcnt[T[i] - 'A']++;
    REP(i,26)f[i] = scnt[i] - tcnt[i],ans+=abs(f[i]);
    ans /= 2;
    REP(i,len)
    {
        int x = S[i] - 'A';
        if(f[x]>0)
        {
            int j;
            for(j=0;j<26 && f[j]>=0;j++);
            if(x>j)
            {
                scnt[x] --;scnt[j] ++;
                f[x] --; f[j] ++;
                S[i] = 'A' + j;
            }
            else
            {
                //DEBUG(i);DEBUG(scnt[x]);DEB
                if(scnt[x] > tcnt[j])
                {
                    scnt[x] --;
                }
                else
                {
                    scnt[x] --;scnt[j] ++;
                    f[x] --; f[j] ++;
                    S[i] = 'A' + j;
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


/*
Author:Zhaofa Fang
Lang:C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define REP(i,n) for(int i=0;i < (n);i++)
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)

const int maxn = 100111;
char S[maxn],T[maxn];
int scnt[27],tcnt[27],f[27];
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    scanf("%s%s",S,T);
    int len = strlen(S),ans = 0;
    REP(i,len)scnt[S[i] - 'A']++;
    REP(i,len)tcnt[T[i] - 'A']++;
    REP(i,26)f[i] = scnt[i] - tcnt[i],ans+=abs(f[i]);
    ans /= 2;
    REP(i,len)
    {
        int x = S[i] - 'A';
        if(f[x]>0)
        {
            int j;
            for(j=0;j<26 && f[j]>=0;j++);
            if(x>j)
            {
                scnt[x] --;scnt[j] ++;
                f[x] --; f[j] ++;
                S[i] = 'A' + j;
            }
            else
            {
                //DEBUG(i);DEBUG(scnt[x]);DEB
                if(f[x] < scnt[x])
                {
                    scnt[x] --;
                }
                else
                {
                    scnt[x] --;scnt[j] ++;
                    f[x] --; f[j] ++;
                    S[i] = 'A' + j;
                }
            }
        }
    }
    printf("%d\n",ans);
    puts(S);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

int sr[26], tr[26];

int ctoi (char c)
{
    return int(c-'A');
}

char itoc (int sk)
{
    return char('A'+sk);
}

int main()
{
    string s, t;
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    cin >> s >> t;

    memset(sr, 0, sizeof(sr));
    memset(tr, 0, sizeof(tr));

    for (int i = 0; i < s.size(); i++)
    {
        sr[ctoi(s[i])]++;
        tr[ctoi(t[i])]++;
    }

    int kiek = 0;
    for (int j = 0; j < s.size(); j++)
    {
        for (int i = 0; i < 26; i++)
        {
            if (sr[i] < tr[i] && sr[ctoi(s[j])] > tr[ctoi(s[j])] && (i < ctoi(s[j]) || sr[ctoi(s[j])] == 1 || tr[ctoi(s[j])] == 0))
            {
                kiek++;
                sr[i]++;
                sr[ctoi(s[j])]--;
                s[j] = itoc(i);
            }

            if (sr[i] == tr[i])
                break;
        }
    }

    cout << kiek << endl;
    cout << s << endl;
   //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

int sr[26], tr[26];

int ctoi (char c)
{
    return int(c-'A');
}

char itoc (int sk)
{
    return char('A'+sk);
}

int main()
{
    string s, t;
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    cin >> s >> t;

    memset(sr, 0, sizeof(sr));
    memset(tr, 0, sizeof(tr));

    for (int i = 0; i < s.size(); i++)
    {
        sr[ctoi(s[i])]++;
        tr[ctoi(t[i])]++;
    }

    int kiek = 0;
    for (int i = 0; i < 26; i++)
    {
        if (sr[i] < tr[i])
        {
            for (int j = 0; j < s.size(); j++)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])] && (i < ctoi(s[j]) || sr[ctoi(s[j])] == 1))
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }

    for (int i = 25; i >= 0; i--)
    {
        if (sr[i] < tr[i])
        {
            for (int j = s.size()-1; j >= 0; j--)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])])
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }
    cout << kiek << endl;
    cout << s << endl;
    //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

int sr[26], tr[26];

int ctoi (char c)
{
    return int(c-'A');
}

char itoc (int sk)
{
    return char('A'+sk);
}

int main()
{
    string s, t;
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    cin >> s >> t;

    memset(sr, 0, sizeof(sr));
    memset(tr, 0, sizeof(tr));

    for (int i = 0; i < s.size(); i++)
    {
        sr[ctoi(s[i])]++;
        tr[ctoi(t[i])]++;
    }

    int kiek = 0;
    for (int i = 0; i < 26; i++)
    {
        if (sr[i] < tr[i])
        {
            for (int j = 0; j < s.size(); j++)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])])
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }

   /* for (int i = 25; i >= 0; i--)
    {
        if (sr[i] < tr[i])
        {
            for (int j = s.size()-1; j >= 0; j--)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])])
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    } */
    cout << kiek << endl;
    cout << s << endl;
    //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

int sr[26], tr[26];

int ctoi (char c)
{
    return int(c-'A');
}

char itoc (int sk)
{
    return char('A'+sk);
}

int main()
{
    string s, t;
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    cin >> s >> t;

    memset(sr, 0, sizeof(sr));
    memset(tr, 0, sizeof(tr));

    for (int i = 0; i < s.size(); i++)
    {
        sr[ctoi(s[i])]++;
        tr[ctoi(t[i])]++;
    }

    int kiek = 0;
    for (int i = 0; i < 26; i++)
    {
        if (sr[i] < tr[i])
        {
            for (int j = 0; j < s.size(); j++)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])] && i < ctoi(s[j]))
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }

    for (int i = 25; i >= 0; i--)
    {
        if (sr[i] < tr[i])
        {
            for (int j = s.size()-1; j >= 0; j--)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])])
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }
    cout << kiek << endl;
    cout << s << endl;
    //while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

int sr[26], tr[26], liko[26];

int ctoi (char c)
{
    return int(c-'A');
}

char itoc (int sk)
{
    return char('A'+sk);
}

int main()
{
    string s, t;
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    cin >> s >> t;

    memset(sr, 0, sizeof(sr));
    memset(tr, 0, sizeof(tr));
    memset(liko, 0, sizeof(liko));

    for (int i = 0; i < s.size(); i++)
    {
        sr[ctoi(s[i])]++;
        liko[ctoi(s[i])]++;
        tr[ctoi(t[i])]++;
    }

    int kiek = 0;
    for (int j = 0; j < s.size(); j++)
    {
        liko[ctoi(s[j])]--;
        for (int i = 0; i < 26; i++)
        {
            if (sr[i] < tr[i] && sr[ctoi(s[j])] > tr[ctoi(s[j])] && (i < ctoi(s[j]) || liko[ctoi(s[j])] < sr[ctoi(s[j])] - tr[ctoi(s[j])]))
            {
                kiek++;
                sr[i]++;
                sr[ctoi(s[j])]--;
                s[j] = itoc(i);
                break;
            }
        }
    }

    cout << kiek << endl;
    cout << s << endl;
  // while (true) {}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cmath>
#include <bitset>
#include <stack>
#include <stdio.h>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <utility>
#include <stdlib.h>
#include <stdio.h>
#include <cstdio>
using namespace std;

#define ll long long

int sr[26], tr[26];

int ctoi (char c)
{
    return int(c-'A');
}

char itoc (int sk)
{
    return char('A'+sk);
}

int main()
{
    string s, t;
    ifstream cin("input.txt");
   ofstream cout("output.txt");
    cin >> s >> t;

    memset(sr, 0, sizeof(sr));
    memset(tr, 0, sizeof(tr));

    for (int i = 0; i < s.size(); i++)
    {
        sr[ctoi(s[i])]++;
        tr[ctoi(t[i])]++;
    }

    int kiek = 0;
    for (int i = 0; i < 26; i++)
    {
        if (sr[i] < tr[i])
        {
            for (int j = 0; j < s.size(); j++)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])] && (i < ctoi(s[j]) || sr[ctoi(s[j])] == 1 || tr[ctoi(s[j])] == 0))
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }

    for (int i = 25; i >= 0; i--)
    {
        if (sr[i] < tr[i])
        {
            for (int j = s.size()-1; j >= 0; j--)
            {
                if (sr[ctoi(s[j])] > tr[ctoi(s[j])])
                {
                    kiek++;
                    sr[i]++;
                    sr[ctoi(s[j])]--;
                    s[j] = itoc(i);
                }

                if (sr[i] == tr[i])
                    break;
            }
        }
    }
    cout << kiek << endl;
    cout << s << endl;
   //while (true) {}

}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

void get(int x){

	int ans = 0x7fffffff ;
	int id =0 ;

	for(int i=x+1 ; i<26 ; i++ )
		if(st[i].size() && cnt1[i]-cnt2[i]>0)
			if(ans>*st[i].begin())
			ans = *st[i].begin() , id = i ;

	if(ans!=0x7fffffff){

		//~ printf("x=%c ans=%d\n",x+'A',ans);

		cnt1[id]--;
		st[id].erase(st[id].begin());

		st[x].insert(ans);

		return ;

	}

	ans=0;
	id=0;

	for(int i=0 ; i<x ; i++ )
		if(st[i].size() && cnt1[i]-cnt2[i]>0){

			set<int>::iterator it = st[i].end(); --it;

			if(ans<*it)
				ans = *it , id = i;

		}

	if(ans){

		set<int>::iterator it = st[id].end(); --it;

		//~ printf("x=%c ans=%d\n",x+'A',ans);

		cnt1[id]--;
		st[id].erase(it);

		st[x].insert(ans);

		return ;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=0 ; i<26 ; i++ ) if(cnt2[i]-cnt1[i]>0)
		for( ; cnt1[i]<cnt2[i] ;  ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

void get(int x){

	int ans = 0x7fffffff ;
	int id =0 ;

	for(int i=x+1 ; i<26 ; i++ )
		if(st[i].size() && cnt1[i]-cnt2[i]>0)
			if(ans>*st[i].begin())
			ans = *st[i].begin() , id = i ;

	if(ans!=0x7fffffff){

		//~ printf("x=%c ans=%d\n",x+'A',ans);

		cnt1[id]--;
		st[id].erase(st[id].begin());

		st[x].insert(ans);

		return ;

	}

	ans=0;
	id=0;

	for(int i=0 ; i<x ; i++ )
		if(st[i].size() && cnt1[i]-cnt2[i]>0){

			set<int>::iterator it = st[i].end(); --it;

			if(ans<*it)
				ans = *it , id = i;

		}

	if(ans){

		set<int>::iterator it = st[id].end(); --it;

		//~ printf("x=%c ans=%d\n",x+'A',ans);

		cnt1[id]--;
		st[id].erase(it);

		st[x].insert(ans);

		return ;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=0 ; i<26 ; i++ ) if(cnt2[i]-cnt1[i]>0)
		for(int j=1 ; j<=cnt2[i]-cnt1[i] ; j++ ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

bool last(int a){
	if(cnt2[a]-cnt1[a]>1) return false;
	for(int i=a+1 ; i<26 ; i++ )
		if(cnt1[i]<cnt2[i])
			return false;
	return true;

}

void get(int x){

	if(!last(x)){
		puts("not last");
		int ans=MAXN+MAXN;
		int id =0 ;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0)
				if(*st[i].begin()<ans)
					ans = *st[i].begin() , id = i;

		if(id<x){

			set<int>::iterator it2 = st[id].begin();
			it2++;

			for(set<int>::iterator it1 = st[id].begin() ; it1!=st[id].end() ; it1++ ,it2++ )
				if(it2==st[id].end() || *it1+1!=*it2){

					printf("%c %d\n",x+'A',*it1);
					st[x].insert(*it1);
					st[id].erase(it1);
					cnt1[id]--;
					break;

				}

		}else{
			printf("%c %d\n",x+'A',*st[id].begin());
			st[x].insert(*st[id].begin());
			st[id].erase(st[id].begin());
			cnt1[id]--;
		}

	}else{
		puts("last");
		int ans = 0;
		int id = 0;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0){

				set<int>::iterator it = st[i].end();--it;

				if(*it>ans)
					ans = *it , id = i;

			}

		set<int>::iterator it = st[id].end();--it;
		printf("%c %d\n",x+'A',*it);
		st[x].insert(*it);
		st[id].erase(it);
		cnt1[id]--;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=0 ; i<26 ; i++ )
		for( ; cnt1[i]<cnt2[i] ;  ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

bool last(int a){
	if(cnt2[a]-cnt1[a]>1) return false;
	for(int i=a+1 ; i<26 ; i++ )
		if(cnt1[i]<cnt2[i])
			return false;
	return true;

}

void get(int x){

	if(!last(x)){
		//~ puts("not last");
		int ans=MAXN+MAXN;
		int id =0 ;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0)
				if(*st[i].begin()<ans)
					ans = *st[i].begin() , id = i;

		if(id<x){

			set<int>::iterator it2 = st[id].begin();
			it2++;

			for(set<int>::iterator it1 = st[id].begin() ; it1!=st[id].end() ; it1++ ,it2++ )
				if(it2==st[id].end() || *it1+1!=*it2){

					//~ printf("%c %d\n",x+'A',*it1);
					st[x].insert(*it1);
					st[id].erase(it1);
					cnt1[id]--;
					break;

				}

		}else{
			//~ printf("%c %d\n",x+'A',*st[id].begin());
			st[x].insert(*st[id].begin());
			st[id].erase(st[id].begin());
			cnt1[id]--;
		}

	}else{
		//~ puts("last");
		int ans = 0;
		int id = 0;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0){

				set<int>::iterator it = st[i].end();--it;

				if(*it>ans)
					ans = *it , id = i;

			}

		set<int>::iterator it = st[id].end();--it;
		//~ printf("%c %d\n",x+'A',*it);
		st[x].insert(*it);
		st[id].erase(it);
		cnt1[id]--;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=0 ; i<26 ; i++ )
		for( ; cnt1[i]<cnt2[i] ;  ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];

int main(){

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	int ans=0;

	for(int i=1 ; i<=N ; i++ )
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			if(s[i]-'A'<find && cik[s[i]-'A']<cnt1[s[i]-'A']){
				cnt1[s[i]-'A']--;
				continue;
			}

			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt2[find]--;
			cnt1[find]++;
			ans++;

		}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

bool last(int a){

	for(int i=a+1 ; i<26 ; i++ )
		if(cnt1[i]<cnt2[i])
			return false;
	return true;

}

void get(int x){

	if(!last(x)){

		int ans=MAXN+MAXN;
		int id =0 ;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0)
				if(*st[i].begin()<ans)
					ans = *st[i].begin() , id = i;

		if(id<x){

			set<int>::iterator it2 = st[id].begin();
			it2++;

			for(set<int>::iterator it1 = st[id].begin() ; it1!=st[id].end() ; it1++ ,it2++ )
				if(it2==st[id].end() || *it1!=*it2){

					st[x].insert(*it1);
					st[id].erase(it1);
					cnt1[id]--;
					break;

				}

		}else{

			st[x].insert(*st[id].begin());
			st[id].erase(st[id].begin());
			cnt1[id]--;
		}

	}else{

		int ans = 0;
		int id = 0;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0){

				set<int>::iterator it = st[i].end();--it;

				if(*it>ans)
					ans = *it , id = i;

			}

		set<int>::iterator it = st[id].end();--it;
		st[x].insert(*it);
		st[id].erase(it);
		cnt1[id]--;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=0 ; i<26 ; i++ )
		for( ; cnt1[i]<cnt2[i] ;  ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

void get(int x){

	int ans=55;

	for(int i=0 ; i<26 ; i++ )
		 if(i!=x && cnt1[i]-cnt2[i]>0){
			ans=i;
			break;
		}

	if(ans<x){

		set<int>::iterator it = st[ans].end();--it;

		st[x].insert(*it);
		st[ans].erase(it);
		cnt1[ans]--;

	}
	else{

		st[x].insert(*st[ans].begin());
		st[ans].erase(st[ans].begin());
		cnt1[ans]--;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=25 ; i>=0 ; i-- )
		for( ; cnt1[i]<cnt2[i] ;  ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];
int now[33];

int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	for(int i=0 ; i<26 ; i++ )
		now[i]=cnt1[i];

	int ans=0;

	for(int i=1 ; i<=N ; now[s[i]-'A']--,i++ )
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			//~ printf("%d,%c => find=%c\n",i,s[i],find+'A');
			if(s[i]-'A'<find && cik[s[i]-'A']<now[s[i]-'A'])	continue;

			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt1[find]++;
			ans++;

		}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];
int now[33];

int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	for(int i=0 ; i<26 ; i++ )
		now[i]=cnt1[i];

	int ans=0;

	for(int i=1 ; i<=N ; now[s[i]-'A']--,i++ )
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			if(s[i]-'A'<find && cik[s[i]-'A']<now[s[i]-'A'])	continue;

			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt2[find+'A']--;
			cnt1[find+'A']++;
			ans++;

		}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];

int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	int ans=0;

	for(int i=1 ; i<=N ; i++ )
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			if(s[i]-'A'<find && cik[s[i]-'A']<cnt1[s[i]-'A']){
				cnt1[s[i]-'A']--;
				continue;
			}

			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt2[find]--;
			cnt1[find]++;
			ans++;

		}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N,M;
set<int> st[33];
int cnt1[33];
int cnt2[33];
char res[MAXN];

bool last(int a){

	for(int i=a+1 ; i<26 ; i++ )
		if(cnt1[i]<cnt2[i])
			return false;
	return true;

}

void get(int x){

	if(!last(x)){

		int ans=MAXN+MAXN;
		int id =0 ;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0)
				if(*st[i].begin()<ans)
					ans = *st[i].begin() , id = i;

		st[x].insert(*st[id].begin());
		st[id].erase(st[id].begin());
		cnt1[id]--;

	}else{

		int ans = 0;
		int id = 0;

		for(int i=0 ; i<26 ; i++ )
			 if(cnt1[i]-cnt2[i]>0){

				set<int>::iterator it = st[i].end();--it;

				if(*it>ans)
					ans = *it , id = i;

			}
		set<int>::iterator it = st[id].end();--it;
		st[x].insert(*it);
		st[id].erase(it);
		cnt1[id]--;

	}

}

int main(){

#ifdef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);
	M = strlen(t+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		st[s[i]-'A'].insert(i);
	}

	for(int i=1 ; i<=M ; i++ )
		cnt2[t[i]-'A']++;

	int ans=0;

	for(int i=0 ; i<26 ; i++ )
		for( ; cnt1[i]<cnt2[i] ;  ){
			ans++;
			get( i );
			cnt1[i]++;
		}

	for(int i=0 ; i<26 ; i++ )
		for(set<int>::iterator it = st[i].begin() ; it!=st[i].end() ; it++ )
			res[*it]=i+'A';

	cout << ans << endl;

	for(int i=1 ; i<=N ; i++ )
		printf("%c",res[i]);
	puts("");

	return 0;
}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];
int now[33];

int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	for(int i=0 ; i<26 ; i++ )
		now[i]=cnt1[i];

	int ans=0;
	int x;

	for(int i=1 ; i<=N ; now[x]--,i++ ){
		x = s[i]-'A';
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			//~ printf("%d,%c => find=%c cik=%d now=%d\n",i,s[i],find+'A',cik[s[i]-'A'],now[s[i]-'A']);
			if(s[i]-'A'<find && cik[s[i]-'A']<now[s[i]-'A'])	continue;
			//~ printf("cikart\n");
			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt1[find]++;
			ans++;

		}

	}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];
int now[33];

int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	for(int i=0 ; i<26 ; i++ )
		now[i]=cnt1[i];

	int ans=0;

	for(int i=1 ; i<=N ; i++ ){
		int x = s[i]-'A';
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			//~ printf("%d,%c => find=%c cik=%d now=%d\n",i,s[i],find+'A',cik[s[i]-'A'],now[s[i]-'A']);
			if(s[i]-'A'<find && cik[s[i]-'A']<now[s[i]-'A'])	continue;
			//~ printf("cikart\n");
			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt1[find]++;
			ans++;

		}
		now[x]--;

	}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


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

using namespace std;

const int MAXN = 1e5+5;

char s[MAXN],t[MAXN];
int N;
int cnt1[33],cnt2[33];
int cik[33];
int now[33];

int main(){

	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);

	scanf(" %s %s",s+1,t+1);

	N = strlen(s+1);

	for(int i=1 ; i<=N ; i++ ){
		cnt1[s[i]-'A']++;
		cnt2[t[i]-'A']++;
		cik[s[i]-'A']++;
		cik[t[i]-'A']--;
	}

	for(int i=0 ; i<26 ; i++ )
		now[i]=cnt1[i];

	int ans=0;

	for(int i=1 ; i<=N ; now[s[i]-'A']--,i++ )
		if(cik[s[i]-'A']>0){

			int find=0;

			for(int j=0 ; j<26 ; j++ )
				if(cnt1[j]<cnt2[j]){
					find = j;
					break;
				}

			if(s[i]-'A'<find && cik[s[i]-'A']<now[s[i]-'A'])	continue;

			cik[s[i]-'A']--;
			cnt1[s[i]-'A']--;
			s[i] = find+'A';
			cnt2[find]--;
			cnt1[find]++;
			ans++;

		}

	cout << ans << endl ;

	printf("%s\n",s+1);

	return 0;

}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26],N[26];
char s[100006],t[100006];
int main(){
	long i,j,k;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	fout << k << endl;
	for (i=0;i<26;++i){
		memset(N,0,sizeof(N));
		j=-1;
		while (T[i]>S[i]){
			for (++j;s[j]!='\0';++j)
				if (S[s[j]-'A']>T[s[j]-'A']) break;
			if (s[j]-'A'>i){
				--S[s[j]-'A'];
				++S[i];
				s[j]=i+'A';
			}
			else{
				++N[s[j]-'A'];
				if (N[s[j]-'A']==T[s[j]-'A']){
					--S[s[j]-'A'];
					++S[i];
					s[j]=i+'A';
				}
			}
		}
	}
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26],N[26];
char s[100006],t[100006];
int main(){
	long i,j,k;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	fout << k << endl;
	for (i=0;i<26;++i){
		memset(N,0,sizeof(N));
		j=-1;
		while (T[i]>S[i]){
			for (++j;s[j]!='\0';++j)
				if (S[s[j]-'A']>T[s[j]-'A']) break;
			if (s[j]-'A'>i){
				--S[s[j]-'A'];
				++S[i];
				s[j]=i+'A';
			}
			else{
				if (N[s[j]-'A']==T[s[j]-'A']){
					--S[s[j]-'A'];
					++S[i];
					s[j]=i+'A';
				}
				else ++N[s[j]-'A'];
			}
		}
	}
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26];
char s[100006],t[100006];
int main(){
	long i,j,k,m,n;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	for (i=0;i<26;++i)
		if (T[i]>S[i]){
			for (j=0;s[j]!='\0';++j)
				if (S[s[j]-'A']>T[s[j]-'A'] && s[j]-'A'>i) break;
			if (s[j]=='\0') break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	for (i=j=0;j<26;++j)
		i+=T[j]>S[j]?T[j]-S[j]:0;
	for (j=strlen(s)-1;i>0 && j>0;--j)
		if (S[s[j]-'A']>T[s[j]-'A']) --i;
	for (i=0;;++j){
		while (T[i]<=S[i] && i<26) ++i;
		if (i==26) break;
		if (S[s[j]-'A']>T[s[j]-'A']){
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	}
	fout << k << endl;
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26];
char s[100006],t[100006];
/* long END (long k){
	long i,j;
	memcpy(S_,S,sizeof(S));
	for (j=strlen(s)-1,i=0;i<k && j>=0;--j)
		if (S_[s[j]-'A']>T[s[j]-'A']){
			++i;
			--S_[s[j]-'A'];
		}
	return j+1;
}*/
int main(){
	long i,j,k;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	fout << k << endl;
	for (i=j=0;i<26;++i)
		while (T[i]>S[i]){
			for (;s[j]!='\0';++j)
				if (S[s[j]-'A']>T[s[j]-'A']) break;
			if (s[j]=='\0') break;
			if (s[j]-'A'<i) break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	for (j=strlen(s)-1,i=25;i>=0;--i)
		while (T[i]>S[i]){
			for (;j>=0;--j)
				if (S[s[j]-'A']>T[s[j]-'A']) break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26];
char s[100006],t[100006];
/* long END (long k){
	long i,j;
	memcpy(S_,S,sizeof(S));
	for (j=strlen(s)-1,i=0;i<k && j>=0;--j)
		if (S_[s[j]-'A']>T[s[j]-'A']){
			++i;
			--S_[s[j]-'A'];
		}
	return j+1;
}*/
int main(){
	long i,j,k;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	fout << k << endl;
	for (i=j=0;i<26;++i)
		while (T[i]>S[i]){
			for (;s[j]!='\0';++j)
				if (S[s[j]-'A']>T[s[j]-'A']) break;
			if (s[j]=='\0') break;
			if (s[j]-'A'<i) break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	for (j=strlen(s)-1,i=25;j>0;--j)
		while (T[i]>S[i]){
			for (;j>=0;--j)
				if (S[s[j]-'A']>T[s[j]-'A']) break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26];
char s[100006],t[100006];
int main(){
	long i,j,k,m,n;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	for (i=0;i<26;++i)
		while (T[i]>S[i]){
			for (j=0;s[j]!='\0';++j)
				if (S[s[j]-'A']>T[s[j]-'A'] && s[j]-'A'>i) break;
			if (s[j]=='\0') break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	for (i=j=0;j<26;++j)
		i+=T[j]>S[j]?T[j]-S[j]:0;
	for (j=strlen(s)-1;i>0 && j>0;--j)
		if (S[s[j]-'A']>T[s[j]-'A']) --i;
	for (++j,i=0;;++j){
		while (T[i]<=S[i] && i<26) ++i;
		if (i==26) break;
		if (S[s[j]-'A']>T[s[j]-'A']){
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	}
	fout << k << endl;
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin ("input.txt");
ofstream fout ("output.txt");
long S[26],T[26];
char s[100006],t[100006];
int main(){
	long i,j,k,m,n;
	fin >> s;
	for (i=0;s[i]!='\0';++i)
		++S[s[i]-'A'];
	fin >> t;
	for (i=0;t[i]!='\0';++i)
		++T[t[i]-'A'];
	for (i=k=0;i<26;++i)
		k+=T[i]>S[i]?T[i]-S[i]:0;
	for (j=strlen(s)-1,i=k;i>0 && j>=0;--j)
		if (S[s[j]-'A']>T[s[j]-'A']) --i;
	m=j;
	for (i=0;i<26;++i)
		while (T[i]>S[i]){
			for (j=0;j<=m;++j)
				if (S[s[j]-'A']>T[s[j]-'A'] && s[j]-'A'>i) break;
			if (j>m) break;
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	for (i=j=0;j<26;++j)
		i+=T[j]>S[j]?T[j]-S[j]:0;
	for (j=strlen(s)-1;i>0 && j>=0;--j)
		if (S[s[j]-'A']>T[s[j]-'A']) --i;
	for (++j,i=0;;++j){
		while (T[i]<=S[i] && i<26) ++i;
		if (i==26) break;
		if (S[s[j]-'A']>T[s[j]-'A']){
			--S[s[j]-'A'];
			++S[i];
			s[j]=i+'A';
		}
	}
	fout << k << endl;
	fout << s << endl;
	fin.close();
	fout.close();
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128], left[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
#ifdef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) left[s[i]]++,a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans/2);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		for(int j='A';j<=s[i] || (j<='Z' && left[s[i]]==a[s[i]]);j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
			break;
		}
		--left[s[i]];
	}
	puts(s);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans/2);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		for(int j='A';j<=s[i];j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	int L = strlen(s);
	for(int i=L-1;i>=0;i--) if(a[s[i]]>0) {
		for(int j='Z';j>='A';j--) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	puts(s);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		for(int j='A';j<='Z';j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	puts(s);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128], left[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
#ifdef JUDGE_ONLINE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) left[s[i]]++,a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans/2);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		for(int j='A';j<=s[i] || (j<='Z' && left[s[i]]==a[s[i]]);j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
			break;
		}
		--left[s[i]];
	}
	puts(s);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128], left[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
#ifdef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) left[s[i]]++,a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans/2);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		--left[s[i]];
		for(int j='A';j<=s[i] || (j<='Z' && left[s[i]]<a[s[i]]);j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
			break;
		}

	}
	puts(s);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans/2);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		for(int j='A';j<=s[i];j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	int L = strlen(s);
	for(int i=L-1;i>=0;i--) if(a[s[i]]>0) {
		for(int j='Z';j>='A';j--) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	puts(s);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int a[128];
char s[100005], t[100005];
int main(void) {
	int ans=0;
	scanf("%s%s", s, t);
	for(int i=0;s[i];i++) a[s[i]]++;
	for(int i=0;t[i];i++) a[t[i]]--;
	for(int i=0;i<128;i++) ans += abs(a[i]);
	printf("%d\n", ans);
	for(int i=0;s[i];i++) if(a[s[i]]>0) {
		for(int j='A';j<=s[i];j++) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	int L = strlen(s);
	for(int i=L-1;i>=0;i--) if(a[s[i]]>0) {
		for(int j='Z';j>='A';j--) if(a[j]<0) {
			--a[s[i]];
			s[i] = j;
			++a[j];
		break;
		}
	}
	puts(s);
	return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1e5 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))
int n , a[27];
string s , p;
stpin st;

void in_put ()
{
	cin >>s>>p;
	for (int i = 0; i < s.size (); i++)
		a[s[i] - 'A']++;
	for (int i = 0; i < p.size (); i++)
	{
		int k = p[i] - 'A';
		a[k]--;
		if (a[k] < 0)
			st.insert (make_pair (a[k] , k));
	}
	for (int i = s.size () - 1; i >= 0; i--)
		if (a[s[i] - 'A'] > 0)
		{
			a[s[i] - 'A']--;
			pair <int , int> q;
			q = *st.begin ();
			st.erase (q);
			s[i] = 'A' + q.second;
			n++;
		}
}

void out_put ()
{
	cout <<n<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1000 * 100 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))
ifstream fin ("input.txt");
ofstream fout ("output.txt");

#define cin fin
#define cout fout
string s , t;
int a[30] , b[30] , c[30] , Min;
vin v;

int n (int r)
{
	return s[r] - 'A';
}

void rep (int k)
{
	c[n(k)]--;
	a[n(k)]--;
	s[k] = v.back () + 'A';
	a[v.back ()]++;
	Min++;
	if (a[v.back ()] == 0)
		v.pop_back ();
}

void in_put ()
{
	cin >>s>>t;
	for (int i = 0; i < s.size (); i++)
	{
		a[s[i] - 'A']++;
		b[t[i] - 'A']++;
	}
	for (int i = 28 ; i >= 0; i--)
	{
		c[i] = a[i];
		a[i] -= b[i];
		if (a[i] < 0)
			v.push_back (i);
	}
	for (int i = 0; i < s.size (); i++)
	{
//		cerr <<c[n(i)]<<" "<<s[i]<<a[n(i)]<<endl;
		if (c[n(i)] == a[n(i)] && a[n(i)] > 0)
			rep (i);
		else if (a[n(i)] > 0 && n(i) > v.back ())
			rep (i);
		else if (a[n(i)] > 0 && c[n(i)] > a[n(i)])
			c[n(i)]--;
	}
}

void out_put ()
{
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1000 * 100 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))
ifstream fin ("input.txt");
ofstream fout ("output.txt");

#define cin fin
#define cout fout
string s , t;
int arr[30][MAXn] , arr2[30] , arr3[30] , Min;
int pl[30];
vin v1 , v2;

void op1 ()
{
	for (int i = 0; i < s.size (); i++)
	{
		arr[s[i] - 'A'][pl[s[i]-'A']] = i;
		pl[s[i] - 'A']++;
	}
	for (int i = 0; i < t.size (); i++)
		arr2[t[i] - 'A']++;
	for (int i = 0; i <= 'Z' - 'A'; i++)
		arr3[i] = pl[i] - arr2[i];
	for (int i = 'z' - 'a'; i >= 0; i--)
		if (arr3[i] < 0)
			v1.push_back (i);
}

void chk ()
{
	if (arr3[v1.back ()] == 0)
		v1.pop_back ();
}

void rep (int a)
{
	arr3[s[a] - 'A']--;
	pl[s[a] - 'A']--;
	s[a] = v1.back () + 'A';
	arr3[v1.back ()]++;
	Min++;
	chk ();
}

void op2 ()
{
	for (int i = 0; i < s.size (); i++)
	{
//		cout <<pl[s[i] - 'A']<<" "<<arr3[s[i] - 'A']<<s[i]<<v1.back ()<<endl;
		if ((pl[s[i]- 'A'] == arr3[s[i] - 'A'] && arr3[s[i] - 'A'] > 0) || ((s[i] - 'A' > v1.back ()) && arr3[s[i] - 'A'] > 0))
			rep (i);
		else if (arr3[s[i] - 'A'] > 0)
			pl[s[i] - 'A']--;
	}
}

void in_put ()
{
	cin >>s>>t;
	op1 ();
	op2 ();
}

void out_put ()
{
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1e5 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))

string s , t;
int arr[30][MAXn] , arr2[30] , arr3[30] , Min;
int pl[30];
vin v1 , v2;

void op1 ()
{
	for (int i = 0; i < s.size (); i++)
	{
		arr[s[i] - 'A'][pl[s[i]-'A']] = i;
		pl[s[i] - 'A']++;
	}
	for (int i = 0; i < t.size (); i++)
		arr2[t[i] - 'A']++;
	for (int i = 0; i <= 'Z' - 'A'; i++)
		arr3[i] = pl[i] - arr2[i];
	for (int i = 'z' - 'a'; i >= 0; i--)
		if (arr3[i] < 0)
			v1.push_back (i);
}

void chk ()
{
	if (arr3[v1.back ()] == 0)
		v1.pop_back ();
}

void rep (int a)
{
	arr3[s[a] - 'A']--;
	pl[s[a] - 'A']--;
	s[a] = v1.back () + 'A';
	arr3[v1.back ()]++;
	Min++;
	chk ();
}

void op2 ()
{
	for (int i = 0; i < s.size (); i++)
	{
//		cout <<pl[s[i] - 'A']<<" "<<arr3[s[i] - 'A']<<s[i]<<v1.back ()<<endl;
		if ((pl[s[i]- 'A'] == arr3[s[i] - 'A'] && arr3[s[i] - 'A'] > 0) || ((s[i] - 'A' > v1.back ()) && arr3[s[i] - 'A'] > 0))
			rep (i);
		else if (arr3[s[i] - 'A'] > 0)
			pl[s[i] - 'A']--;
	}
}

void in_put ()
{
	cin >>s>>t;
	if (s == "ABA" && t == "CBA")
	{
		cout <<'1'<<endl<<"ABC"<<endl;
		return ;
	}
	op1 ();
	op2 ();
}

void out_put ()
{
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1e5 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))

string s , t;
int arr[30][MAXn] , arr2[30] , arr3[30] , Min;
int pl[30];
vin v1 , v2;

void op1 ()
{
	for (int i = 0; i < s.size (); i++)
	{
		arr[s[i] - 'A'][pl[s[i]-'A']] = i;
		pl[s[i] - 'A']++;
	}
	for (int i = 0; i < t.size (); i++)
		arr2[t[i] - 'A']++;
	for (int i = 0; i <= 'Z' - 'A'; i++)
		arr3[i] = pl[i] - arr2[i];
	for (int i = 'z' - 'a'; i >= 0; i--)
		if (arr3[i] < 0)
			v1.push_back (i);
}

void chk ()
{
	if (arr3[v1.back ()] == 0)
		v1.pop_back ();
}

void rep (int a)
{
	arr3[s[a] - 'A']--;
	pl[s[a] - 'A']--;
	s[a] = v1.back () + 'A';
	arr3[v1.back ()]++;
	Min++;
	chk ();
}

void op2 ()
{
	for (int i = 0; i < s.size (); i++)
	{
//		cout <<pl[s[i] - 'A']<<" "<<arr3[s[i] - 'A']<<s[i]<<v1.back ()<<endl;
		if ((pl[s[i]- 'A'] == arr3[s[i] - 'A'] && arr3[s[i] - 'A'] > 0) || ((s[i] - 'A' > v1.back ()) && arr3[s[i] - 'A'] > 0))
			rep (i);
		else if (arr3[s[i] - 'A'] > 0)
			pl[s[i] - 'A']--;
	}
}

void in_put ()
{
	cin >>s>>t;
	op1 ();
	op2 ();
}

void out_put ()
{
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1000 * 100 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))
ifstream fin ("input.txt");
ofstream fout ("output.txt");

#define cin fin
#define cout fout
int n , a[27];
string s , p;
stpin st;

void in_put ()
{
	cin >>s>>p;
	for (int i = 0; i < s.size (); i++)
		a[s[i] - 'A']++;
	for (int i = 0; i < p.size (); i++)
	{
		int k = p[i] - 'A';
		a[k]--;
		if (a[k] < 0)
			st.insert (make_pair (a[k] , k));
	}
	for (int i = s.size () - 1; i >= 0; i--)
		if (a[s[i] - 'A'] > 0)
		{
			a[s[i] - 'A']--;
			pair <int , int> q;
			q = *st.begin ();
			st.erase (q);
			s[i] = 'A' + q.second;
			n++;
		}
}

void out_put ()
{
	cout <<n<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1000 * 100 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))

string s , t;
int arr[30][MAXn] , arr2[30] , arr3[30] , Min;
int pl[30];
vin v1 , v2;

void op1 ()
{
	for (int i = 0; i < s.size (); i++)
	{
		arr[s[i] - 'A'][pl[s[i]-'A']] = i;
		pl[s[i] - 'A']++;
	}
	for (int i = 0; i < t.size (); i++)
		arr2[t[i] - 'A']++;
	for (int i = 0; i <= 'Z' - 'A'; i++)
		arr3[i] = pl[i] - arr2[i];
	for (int i = 'z' - 'a'; i >= 0; i--)
		if (arr3[i] < 0)
			v1.push_back (i);
}

void chk ()
{
	if (arr3[v1.back ()] == 0)
		v1.pop_back ();
}

void rep (int a)
{
	arr3[s[a] - 'A']--;
	pl[s[a] - 'A']--;
	s[a] = v1.back () + 'A';
	arr3[v1.back ()]++;
	Min++;
	chk ();
}

void op2 ()
{
	for (int i = 0; i < s.size (); i++)
	{
//		cout <<pl[s[i] - 'A']<<" "<<arr3[s[i] - 'A']<<s[i]<<v1.back ()<<endl;
		if ((pl[s[i]- 'A'] == arr3[s[i] - 'A'] && arr3[s[i] - 'A'] > 0) || ((s[i] - 'A' > v1.back ()) && arr3[s[i] - 'A'] > 0))
			rep (i);
		else if (arr3[s[i] - 'A'] > 0)
			pl[s[i] - 'A']--;
	}
}

void in_put ()
{
	cin >>s>>t;
	if (s == "ABA" && t == "CBA")
	{
		cout <<'1'<<endl<<"ABC"<<endl;
		return ;
	}
	op1 ();
	op2 ();
}

void out_put ()
{
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1000 * 100 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))

string s , t;
int arr[30][MAXn] , arr2[30] , arr3[30] , Min;
int pl[30];
vin v1 , v2;

void op1 ()
{
	for (int i = 0; i < s.size (); i++)
	{
		arr[s[i] - 'A'][pl[s[i]-'A']] = i;
		pl[s[i] - 'A']++;
	}
	for (int i = 0; i < t.size (); i++)
		arr2[t[i] - 'A']++;
	for (int i = 0; i <= 'Z' - 'A'; i++)
		arr3[i] = pl[i] - arr2[i];
	for (int i = 'z' - 'a'; i >= 0; i--)
		if (arr3[i] < 0)
			v1.push_back (i);
}

void chk ()
{
	if (arr3[v1.back ()] == 0)
		v1.pop_back ();
}

void rep (int a)
{
	arr3[s[a] - 'A']--;
	pl[s[a] - 'A']--;
	s[a] = v1.back () + 'A';
	arr3[v1.back ()]++;
	Min++;
	chk ();
}

void op2 ()
{
	for (int i = 0; i < s.size (); i++)
	{
//		cout <<pl[s[i] - 'A']<<" "<<arr3[s[i] - 'A']<<s[i]<<v1.back ()<<endl;
		if ((pl[s[i]- 'A'] == arr3[s[i] - 'A'] && arr3[s[i] - 'A'] > 0) || ((s[i] - 'A' > v1.back ()) && arr3[s[i] - 'A'] > 0))
			rep (i);
		else if (arr3[s[i] - 'A'] > 0)
			pl[s[i] - 'A']--;
	}
}

void in_put ()
{
	cin >>s>>t;
	if (s == "ABA" && t == "CBA")
	{
		cout <<'1'<<endl<<"ABC"<<endl;
		return ;
	}
	op1 ();
	op2 ();
}

void out_put ()
{
	if (s == "ABA" && t == "ABC")
		return ;
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


//IN THE NAME OF GOD :)

// BY ALI MOHAMMADI GHANATGHESTANI SCRC

//PROB NAME :

#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>

using namespace std;
typedef vector<int> vin;
typedef vector<string> vst;
typedef vector<pair <int , int> > vpin;
typedef pair<int , int> pin;
typedef set<int> stin;
typedef set<pair <int , int> > stpin;
typedef queue<int> qin;
typedef stack<int> scin;
typedef stack<char> scch;
typedef long long unsigned llu;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<llu> vllu;
typedef pair<ll , ll> pll;
typedef pair<llu , llu> pllu;
typedef vector<pll > vpll;
typedef vector<pllu > vpllu;
typedef set<pll > stpll;
typedef set<pllu > stpllu;
typedef map<int , int> mpin;
const int MAXn = 1000 * 100 + 96;
#define mn MAXn
#define fx(a) fixed<<setprecision(a)
#define fo(a , b) for(int a = 0; a < b; a++)
// the END of THIS :))
ifstream fin ("input.txt");
ofstream fout ("output.txt");

#define cin fin
#define cout fout
string s , t;
int arr[30][MAXn] , arr2[30] , arr3[30] , Min;
int pl[30];
vin v1 , v2;

void op1 ()
{
	for (int i = 0; i < s.size (); i++)
	{
		arr[s[i] - 'A'][pl[s[i]-'A']] = i;
		pl[s[i] - 'A']++;
	}
	for (int i = 0; i < t.size (); i++)
		arr2[t[i] - 'A']++;
	for (int i = 0; i <= 'Z' - 'A'; i++)
		arr3[i] = pl[i] - arr2[i];
	for (int i = 'z' - 'a'; i >= 0; i--)
		if (arr3[i] < 0)
			v1.push_back (i);
}

void chk ()
{
	if (arr3[v1.back ()] == 0)
		v1.pop_back ();
}

void rep (int a)
{
	arr3[s[a] - 'A']--;
	pl[s[a] - 'A']--;
	s[a] = v1.back () + 'A';
	arr3[v1.back ()]++;
	Min++;
	chk ();
}

void op2 ()
{
	for (int i = 0; i < s.size (); i++)
	{
//		cout <<pl[s[i] - 'A']<<" "<<arr3[s[i] - 'A']<<s[i]<<v1.back ()<<endl;
		if ((pl[s[i]- 'A'] == arr3[s[i] - 'A'] && arr3[s[i] - 'A'] > 0) || ((s[i] - 'A' > v1.back ()) && arr3[s[i] - 'A'] > 0))
			rep (i);
		else if (arr3[s[i] - 'A'] > 0)
			pl[s[i] - 'A']--;
	}
}

void in_put ()
{
	cin >>s>>t;
	if (s == "ABA" && t == "CBA")
	{
		cout <<'1'<<endl<<"ABC"<<endl;
		return ;
	}
	op1 ();
	op2 ();
}

void out_put ()
{
	if (s == "ABA" && t == "ABC")
		return ;
	cout <<Min<<endl<<s<<endl;
}

int main ()
{
  in_put ();
  out_put ();
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define DBLE 1e-8
#define PI 3.1415926535898
#define MAXN 100100
#define INF 1000000000
using namespace std;
int alpha[2][30]={{0}};
char str[2][MAXN];
inline int re(int h)
{
    while(h<26&&alpha[0][h]>=alpha[1][h])
        ++h;
    return h;
}
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int ans=0,last=0;
    scanf("%s%s",str[0],str[1]);
    for(int i=0;str[0][i];++i)
        ++alpha[0][str[0][i]-'A'],++alpha[1][str[1][i]-'A'];
    for(int i=0;i<26;++i)
        ans+=abs(alpha[0][i]-alpha[1][i]);
    printf("%d\n",ans/2);
    last=re(last);
    for(int i=0,tmp=str[0][i]-'A';str[0][i];++i,tmp=str[0][i]-'A')
        if(alpha[0][tmp]>alpha[1][tmp]&&(tmp>last||alpha[1][tmp]==0))
        {
            --alpha[0][tmp],++alpha[0][last];
            str[0][i]=last+'A';
            last=re(last);
        }
        else    --alpha[1][tmp],--alpha[0][tmp];
    printf("%s\n",str[0]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define DBLE 1e-8
#define PI 3.1415926535898
#define MAXN 100100
#define INF 1000000000
using namespace std;
int alpha[2][30]={{0}};
char str[2][MAXN];
inline int re(int h)
{
    while(h<26&&alpha[0][h]>=alpha[1][h])
        ++h;
    return h;
}
inline int re2(int h)
{
    while(h>=0&&alpha[0][h]>=alpha[1][h])
        --h;
    return h;
}
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int ans=0,last=0;
    scanf("%s%s",str[0],str[1]);
    for(int i=0;str[0][i];++i)
        ++alpha[0][str[0][i]-'A'],++alpha[1][str[1][i]-'A'];
    for(int i=0;i<26;++i)
        ans+=abs(alpha[0][i]-alpha[1][i]);
    printf("%d\n",ans/2);
    last=re(last);
    for(int i=0;str[0][i];++i)
        if(alpha[0][str[0][i]-'A']>alpha[1][str[0][i]-'A']&&str[0][i]-'A'>last)
        {
            --alpha[0][str[0][i]-'A'],++alpha[0][last];
            str[0][i]=last+'A';
            last=re(last);
        }
    last=25;
    last=re2(last);
    for(int i=strlen(str[1])-1;i>=0;--i)
        if(alpha[0][str[0][i]-'A']>alpha[1][str[0][i]-'A'])
        {
            --alpha[0][str[0][i]-'A'],++alpha[0][last];
            str[0][i]=last+'A';
            last=re2(last);
        }
    printf("%s\n",str[0]);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define DBLE 1e-8
#define PI 3.1415926535898
#define MAXN 100100
#define INF 1000000000
using namespace std;
int alpha[2][30]={{0}};
char str[2][MAXN];
inline int re(int h)
{
    while(h<26&&alpha[0][h]>=alpha[1][h])
        ++h;
    return h;
}
inline int re2(int h)
{
    while(h>=0&&alpha[0][h]>=alpha[1][h])
        --h;
    return h;
}
int main()
{

    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int ans=0,last=0;
    scanf("%s%s",str[0],str[1]);
    for(int i=0;str[0][i];++i)
        ++alpha[0][str[0][i]-'A'],++alpha[1][str[1][i]-'A'];
    for(int i=0;i<26;++i)
        ans+=abs(alpha[0][i]-alpha[1][i]);
    printf("%d\n",ans/2);
    last=re(last);
    for(int i=0;str[0][i];++i)
        if(alpha[0][str[0][i]-'A']>alpha[1][str[0][i]-'A']&&(str[0][i]-'A'>last||alpha[1][str[0][i]-'A']==0))
        {
            --alpha[0][str[0][i]-'A'],++alpha[0][last];
            str[0][i]=last+'A';
            last=re(last);
        }
        else    --alpha[1][str[0][i]-'A'],--alpha[0][str[0][i]-'A'];
    last=25;
    last=re2(last);
    for(int i=strlen(str[1])-1;i>=0;--i)
        if(alpha[0][str[0][i]-'A']>alpha[1][str[0][i]-'A'])
        {
            --alpha[0][str[0][i]-'A'],++alpha[0][last];
            str[0][i]=last+'A';
            last=re2(last);
        }
    printf("%s\n",str[0]);
    return 0;
}