#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost, flow, link;
  edge(int to, int cost, int flow, int link)
      : to(to), cost(cost), flow(flow), link(link) {}
};
int ans, m, i, j, h, n, q1, q2, q, k, a[2000001], b[2000001], d[55][55],
    potx[55], poty[55], minpot[55], curx, cury, delta, way[55], pairx[55],
    pairy[55];
char buf[2000010];
bool usedx[55], usedy[55], succ;
void solve() {
  scanf("%d%d\n", &k, &n);
  scanf("%s\n", &buf);
  for (j = 0; j < k; j++) {
    if (buf[j] <= 'Z') {
      a[j + 1] = buf[j] - 'A' + 27;
    } else {
      a[j + 1] = buf[j] - 'a' + 1;
    }
  }
  scanf("%s\n", &buf);
  for (j = 0; j < k; j++) {
    if (buf[j] <= 'Z') {
      b[j + 1] = buf[j] - 'A' + 27;
    } else {
      b[j + 1] = buf[j] - 'a' + 1;
    }
    d[a[j + 1]][b[j + 1]]++;
  }
  q = 0;
  for (j = 1; j <= n; j++) {
    for (i = 1; i <= n; i++) {
      d[j][i] *= -1;
      q = min(q, d[j][i]);
    }
  }
  for (j = 1; j <= n; j++) {
    for (i = 1; i <= n; i++) {
      d[j][i] -= q;
    }
  }
  for (j = 1; j <= n; j++) {
    curx = j;
    memset(usedx, 0, sizeof(usedx));
    memset(usedy, 0, sizeof(usedy));
    memset(minpot, 127, sizeof(minpot));
    succ = 0;
    while (!succ) {
      usedx[curx] = 1;
      cury = 0;
      for (i = 1; i <= n; i++) {
        minpot[i] = min(minpot[i], d[curx][i] - poty[i] - potx[curx]);
        if (minpot[i] < minpot[cury] && !usedy[i]) {
          cury = i;
        }
      }
      delta = minpot[cury];
      for (i = 1; i <= n; i++) {
        if (usedx[i]) {
          potx[i] += delta;
        }
        if (usedy[i]) {
          poty[i] -= delta;
        } else {
          minpot[i] -= delta;
        }
      }
      for (i = 1; i <= n; i++) {
        if (usedx[i] && !(d[i][cury] - potx[i] - poty[cury])) {
          way[cury] = i;
          break;
        }
      }
      usedy[cury] = 1;
      if (pairy[cury]) {
        curx = pairy[cury];
      } else {
        succ = 1;
        do {
          q = pairx[way[cury]];
          pairy[cury] = way[cury];
          pairx[way[cury]] = cury;
          cury = q;
        } while (cury);
      }
    }
  }
  for (j = 1; j <= k; j++) {
    if (pairx[a[j]] == b[j]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  for (j = 1; j <= n; j++) {
    if (pairx[j] <= 26) {
      printf("%c", pairx[j] + 'a' - 1);
    } else {
      printf("%c", pairx[j] + 'A' - 27);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
