func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, fre[11], fre1[11];   string tot, no, cm =   , cm1 =   ;   bool belongs(int x) {     int tmp = x, len = 0, i;     int tmf[11] = {};     while (tmp > 0) {       tmf[(tmp % 10)]++;       tmp /= 10;       len++;     }     if (n - len == x) {       for (i = 0; i < 10; i++) {         if (fre1[i] < tmf[i]) return false;       }       return true;     }     return false;   }   int main() {     int i, j;     cin >> tot;     cin >> no;     if (tot ==  01  || tot ==  10 ) {       cout <<  0 n ;       return 0;     }     n = tot.length();     m = no.length();     for (i = 0; i < n; i++) {       fre[tot[i] - 48]++;       fre1[tot[i] - 48]++;     }     for (i = 0; i < m; i++) {       fre1[no[i] - 48]--;     }     for (i = 1; i <= n; i++) {       if (belongs(i)) {         int tmp = i;         while (tmp > 0) {           fre1[(tmp % 10)]--;           tmp /= 10;         }         break;       }     }     int tm;     for (i = 0; i < 10; i++) {       tm = fre1[i];       while (tm > 0) {         cm1 += (i + 48);         tm--;       }     }     for (i = 1; i < 10; i++) {       if (fre1[i] > 0) {         cm += (i + 48);         fre1[i]--;         break;       }     }     for (i = 0; i < 10; i++) {       tm = fre1[i];       while (tm > 0) {         cm += (i + 48);         tm--;       }     }     if (no[0] ==  0 ) {       i = 1;       n = cm.size();       while (i < n && cm[i] < no[0]) {         i++;       }       string ans1 =   , ans2 =   ;       for (j = 0; j < min(i, n); j++) ans1 += cm[j];       ans1 += no;       for (j = i; j < n; j++) ans1 += cm[j];       i = 1;       while (i < n && cm[i] <= no[0]) {         i++;       }       for (j = 0; j < min(i, n); j++) ans2 += cm[j];       ans2 += no;       for (j = i; j < n; j++) ans2 += cm[j];       string ans;       if (ans1[0] !=  0 ) {         ans = ans1;       } else if (ans2[0] !=  0 ) {         ans = ans2;       }       if (ans1[0] !=  0 ) {         ans = min(ans, ans1);       }       if (ans2[0] !=  0 ) {         ans = min(ans, ans2);       }       cout << ans << endl;     } else {       string ans3 = no + cm1;       i = 1;       n = cm.size();       while (i < n && cm[i] < no[0]) {         i++;       }       string ans1 =   , ans2 =   ;       for (j = 0; j < min(i, n); j++) ans1 += cm[j];       ans1 += no;       for (j = i; j < n; j++) ans1 += cm[j];       i = 1;       while (i < n && cm[i] <= no[0]) {         i++;       }       for (j = 0; j < min(i, n); j++) ans2 += cm[j];       ans2 += no;       for (j = i; j < n; j++) ans2 += cm[j];       string ans;       if (ans1[0] !=  0 ) {         ans = ans1;       } else if (ans2[0] !=  0 ) {         ans = ans2;       } else if (ans3[0] !=  0 ) {         ans = ans3;       }       if (ans1[0] !=  0 ) {         ans = min(ans, ans1);       }       if (ans2[0] !=  0 ) {         ans = min(ans, ans2);       }       if (ans3[0] !=  0 ) {         ans = min(ans, ans3);       }       cout << ans << endl;     }     return 0;   }   