#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int v, c, w;
  node *next, *pair;
};
const int MAXN = 110;
const int INF = 1000000000;
node *x[MAXN];
int vn, en, flow, cost, dist[MAXN];
int s, t;
bool z[MAXN];
int newnode(int s, int t, int w, int c = INF) {
  node xs = {t, c, w, x[s], 0}, xt = {s, 0, -w, x[t], 0};
  x[s] = new node(xs);
  x[t] = new node(xt);
  x[s]->pair = x[t];
  x[t]->pair = x[s];
  return 0;
}
int augment(int now, int m) {
  if (now == t) return cost += dist[s] * m, flow += m, m;
  z[now] = true;
  for (node *p = x[now]; p; p = p->next)
    if (p->c && !z[p->v] && (dist[p->v] + p->w == dist[now]))
      if (int d = augment(p->v, m < p->c ? m : p->c))
        return p->c -= d, p->pair->c += d, d;
  return 0;
}
bool relabel() {
  int d = INF, w;
  for (int i = 1; i <= vn; ++i)
    if (z[i])
      for (node *p = x[i]; p; p = p->next)
        if (p->c && !z[p->v])
          if ((w = p->w - dist[i] + dist[p->v]) < d) d = w;
  if (d == INF) return 0;
  for (int i = 1; i <= vn; ++i)
    if (z[i]) dist[i] += d;
  return 1;
}
int f(char c) {
  if ((c >= 'a') && (c <= 'z')) return c - 'a';
  return c - 'A' + 26;
}
char invF(int i) {
  if (i < 26) return 'a' + i;
  return 'A' + i - 26;
}
int main() {
  int n, k;
  string s1, s2;
  cin >> n >> k >> s1 >> s2;
  vn = k * 2 + 2;
  s = 1;
  t = vn;
  int sum[k];
  int cnt[k][k];
  for (int i = 0; i < k; ++i) sum[i] = 0;
  for (int i = 0; i < k; ++i)
    for (int j = 0; j < k; ++j) cnt[i][j] = 0;
  for (int i = 0; i < n; ++i) {
    sum[f(s1[i])]++;
    cnt[f(s1[i])][f(s2[i])]++;
  }
  for (int i = 0; i < k; ++i) {
    newnode(1, i + 2, 0, 1);
    newnode(i + k + 2, vn, 0, 1);
    for (int j = 0; j < k; ++j)
      newnode(i + 2, j + k + 2, sum[i] - cnt[i][j], 1);
  }
  do do
      memset(z, 0, sizeof(z));
    while (augment(s, INF));
  while (relabel());
  cout << n - cost << endl;
  for (int i = 0; i < k; ++i)
    for (node *p = x[i + 2]; p; p = p->next)
      if (p->c == 0) cout << invF(p->v - 2 - k);
  cout << endl;
}
