#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 60 + 5;
const int maxl = 2000000 + 5;
int encode(char ch) { return islower(ch) ? ch - 'a' : ch - 'A' + 26; }
char decode(int cd) { return cd < 26 ? 'a' + cd : 'A' + cd - 26; }
class KM {
  int n, w[maxn][maxn];
  int res, match[maxn], lx[maxn], ly[maxn], slk[maxn];
  bool s[maxn], t[maxn];
  bool aug(int u) {
    s[u] = true;
    for (int v = 0; v < n; ++v)
      if (!t[v]) {
        if (lx[u] + ly[v] == w[u][v]) {
          t[v] = true;
          if (match[v] == -1 || aug(match[v])) {
            match[v] = u;
            return true;
          }
        } else {
          slk[v] = min(slk[v], lx[u] + ly[v] - w[u][v]);
        }
      }
    return false;
  }

 public:
  void init(int n) {
    this->n = n;
    memset(w, 0, sizeof(w));
  }
  void add_edge(int u, int v) { ++w[u][v]; }
  void max_match() {
    res = 0;
    memset(match, -1, sizeof(match));
    for (int i = 0; i < n; ++i) lx[i] = *max_element(w[i], w[i] + n), ly[i] = 0;
    for (int i = 0; i < n; ++i) {
      memset(slk, 0x3f, sizeof(slk));
      while (true) {
        memset(s, false, sizeof(s));
        memset(t, false, sizeof(t));
        if (aug(i)) break;
        int d = inf;
        for (int i = 0; i < n; ++i)
          if (!t[i]) d = min(d, slk[i]);
        for (int i = 0; i < n; ++i) {
          if (s[i]) lx[i] -= d;
          if (t[i])
            ly[i] += d;
          else
            slk[i] -= d;
        }
      }
    }
    int link[maxn];
    for (int i = 0; i < n; ++i)
      if (match[i] != -1) {
        res += w[match[i]][i];
        link[match[i]] = i;
      }
    printf("%d\n", res);
    for (int i = 0; i < (n); ++i) putchar(decode(link[i]));
    puts("");
  }
} grp;
int n, k;
char s1[maxl], s2[maxl];
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s%s", s1, s2);
  grp.init(k);
  for (int i = 0; i < (n); ++i) grp.add_edge(encode(s1[i]), encode(s2[i]));
  grp.max_match();
  return 0;
}
