#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
char a[2100000], b[2100000];
int dis[220], st[220], c[220 * 220], Next[220 * 220], head[220], e[220 * 220],
    len, v[220 * 220], S, T, flag[220], bfs[220 * 1000];
int dv[220][220], n, Id[220][220], m;
int ch(char c) {
  if (c >= 'a' && c <= 'z') return c - 'a' + 1;
  return c - 'A' + 27;
}
void addedge(int x, int y, int w) {
  Next[++len] = head[x];
  head[x] = len;
  e[len] = y;
  c[len] = 1;
  v[len] = w;
  Next[++len] = head[y];
  head[y] = len;
  e[len] = x;
  c[len] = 0;
  v[len] = -w;
}
int Costflow() {
  int l, r, ans = 0;
  for (;;) {
    for (int i = 1; i <= T; ++i) dis[i] = -1 << 30;
    dis[S] = 0;
    bfs[l = r = 1] = S;
    while (l <= r) {
      int x = bfs[l++], y;
      flag[x] = 0;
      for (int i = head[x]; i; i = Next[i])
        if (c[i] && dis[x] + v[i] > dis[y = e[i]]) {
          dis[y] = dis[x] + v[i];
          st[y] = i;
          if (!flag[y]) {
            flag[y] = 1;
            bfs[++r] = y;
          }
        }
    }
    if (dis[T] < -1000) return ans;
    for (int i = T; i != S; i = e[st[i] ^ 1]) c[st[i]]--, c[st[i] ^ 1]++;
    ans += dis[T];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s%s", a + 1, b + 1);
  for (int i = 1; i <= n; ++i) dv[ch(a[i])][ch(b[i])]++;
  S = 2 * m + 1;
  T = S + 1;
  len = 1;
  for (int i = 1; i <= m; ++i) {
    addedge(S, i, 0);
    for (int j = 1; j <= m; ++j) {
      Id[i][j] = len + 1;
      addedge(i, j + m, dv[i][j]);
    }
    addedge(i + m, T, 0);
  }
  printf("%d\n", Costflow());
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= m; ++j)
      if (c[Id[i][j]] == 0) {
        printf("%c", (j <= 26 ? 'a' + j - 1 : 'A' + j - 27));
        break;
      }
}
