#include <bits/stdc++.h>
const int N = 200;
char s[N], A[2000050], B[2000050];
int k, p[N], w[N][N];
int lx[N], ly[N], wx[N], wy[N], slack[N];
bool visx[N], visy[N];
bool dfs(int x) {
  visx[x] = true;
  for (int y = 0; y < k; ++y)
    if (!visy[y]) {
      int t = wx[x] + wy[y] - w[x][y];
      if (!t) {
        visy[y] = true;
        if (ly[y] == -1 || dfs(ly[y])) {
          lx[ly[y] = x] = y;
          return true;
        }
      } else
        slack[y] = std::min(slack[y], t);
    }
  return false;
}
int KM() {
  memset(lx, -1, sizeof lx);
  memset(ly, -1, sizeof ly);
  for (int i = 0; i < k; ++i) {
    wx[i] = wy[i] = 0;
    for (int j = 0; j < k; ++j) wx[i] = std::max(wx[i], w[i][j]);
  }
  for (int i = 0; i < k; ++i) {
    memset(slack, 0x3f, sizeof slack);
    while (true) {
      memset(visx, 0, sizeof visx);
      memset(visy, 0, sizeof visy);
      if (dfs(i)) break;
      int d = 0x3f3f3f3f;
      for (int i = 0; i < k; ++i)
        if (!visy[i]) d = std::min(d, slack[i]);
      for (int i = 0; i < k; ++i)
        if (visx[i]) wx[i] -= d;
      for (int i = 0; i < k; ++i)
        if (visy[i])
          wy[i] += d;
        else
          slack[i] -= d;
    }
  }
  int ans = 0;
  for (int i = 0; i < k; ++i) ans += wx[i] + wy[i];
  return ans;
}
int main() {
  int n;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; ++i) p[s[i] = i < 26 ? 'a' + i : 'A' + (i - 26)] = i;
  scanf("%s%s", A, B);
  for (int i = 0; i < n; ++i) ++w[p[A[i]]][p[B[i]]];
  int ans = KM();
  printf("%d\n", ans);
  for (int i = 0; i < k; ++i) putchar(s[lx[i]]);
  return 0;
}
