#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
class MinCostFlow1 {
 public:
  int S, T, ecnt;
  int head[1000];
  long long c[10000];
  long long w[10000], dis[1000];
  int to[10000], next[10000];
  bool use[1000];
  MinCostFlow1() {
    memset(head, 0, sizeof(head));
    ecnt = 2;
  }
  void add_edge(int u, int v, long long _c, long long ww) {
    c[ecnt] = _c;
    w[ecnt] = ww;
    to[ecnt] = v;
    next[ecnt] = head[u];
    head[u] = ecnt++;
    c[ecnt] = 0;
    w[ecnt] = -ww;
    to[ecnt] = u;
    next[ecnt] = head[v];
    head[v] = ecnt++;
  }
  void SPFA() {
    for (int i = 1; i <= T; ++i) dis[i] = (1LL << 50);
    priority_queue<pair<long long, int> > Q;
    dis[S] = 0;
    Q.push(make_pair(0, S));
    while (!Q.empty()) {
      int u = Q.top().second;
      long long d = -Q.top().first;
      Q.pop();
      if (dis[u] != d) continue;
      for (int p = head[u]; p; p = next[p]) {
        int &v = to[p];
        if (c[p] && dis[v] > d + w[p]) {
          dis[v] = d + w[p];
          Q.push(make_pair(-dis[v], v));
        }
      }
    }
    for (int i = 1; i <= T; ++i) dis[i] = dis[T] - dis[i];
  }
  long long add_flow(int u, long long flow, long long &minCost) {
    if (u == T) {
      minCost += dis[S] * flow;
      return flow;
    }
    use[u] = true;
    long long now = flow;
    for (int p = head[u]; p; p = next[p]) {
      int &v = to[p];
      if (c[p] && !use[v] && dis[u] == dis[v] + w[p]) {
        long long tmp = add_flow(v, min(now, c[p]), minCost);
        c[p] -= tmp;
        c[p ^ 1] += tmp;
        now -= tmp;
        if (!now) break;
      }
    }
    return flow - now;
  }
  bool modify_label() {
    long long d = (1LL << 50);
    for (int u = 1; u <= T; ++u)
      if (use[u])
        for (int p = head[u]; p; p = next[p]) {
          int &v = to[p];
          if (c[p] && !use[v]) d = min(d, dis[v] + w[p] - dis[u]);
        }
    if (d == (1LL << 50)) return false;
    for (int i = 1; i <= T; ++i)
      if (use[i]) dis[i] += d;
    return true;
  }
  pair<long long, long long> mincostflow(int s, int t) {
    S = s;
    T = t;
    SPFA();
    long long flw = 0;
    long long minCost = 0;
    while (true) {
      while (true) {
        for (int i = 1; i <= T; ++i) use[i] = 0;
        long long tt = add_flow(S, (1LL << 50), minCost);
        flw += tt;
        if (!tt) break;
      }
      if (!modify_label()) break;
    }
    return {flw, minCost};
  }
  vector<pair<int, int> > getEdge(int k) {
    vector<pair<int, int> > ans;
    for (int(i) = 1; (i) <= (int)(T); (i)++)
      for (int j = head[i]; j > 0; j = next[j])
        if (c[j] == 0) {
          if (i >= 1 && i <= k) ans.push_back(make_pair(i, to[j]));
        }
    return ans;
  }
};
int a[55][55], ta[100];
char s[2000105], t[2000105];
int gg(char c) { return c <= 'z' && c >= 'a' ? c - 'a' : c - 'A' + 26; }
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s%s", s, t);
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    int x = gg(s[i]), y = gg(t[i]);
    if (x < k && y < k) a[x + 1][y + 1]++;
  }
  int N = 2 + k + k, st = N - 1, ed = N;
  MinCostFlow1 mf = MinCostFlow1();
  mf.S = st;
  mf.T = ed;
  for (int(i) = 1; (i) <= (int)(k); (i)++) {
    mf.add_edge(st, i, 1, 0);
    for (int(j) = 1; (j) <= (int)(k); (j)++) mf.add_edge(i, k + j, 1, -a[i][j]);
    mf.add_edge(k + i, ed, 1, 0);
  }
  auto ans = mf.mincostflow(st, ed);
  cout << -ans.second << endl;
  auto vp = mf.getEdge(k);
  for (auto p : vp) ta[p.first] = p.second;
  for (int(i) = 1; (i) <= (int)(k); (i)++) {
    int x = ta[i] - k;
    if (x <= 26)
      printf("%c", (x - 1) + 'a');
    else
      printf("%c", (x - 1 - 26) + 'A');
  }
  puts("");
  return 0;
}
