#include <bits/stdc++.h>
using namespace std;
static const int INF = 1000000007;
class KuhnMunkras {
 public:
  static const int SIZE = 60;
  int sum;
  int cnt, pos[SIZE], neg[SIZE];
  int gao(int n, const int e[SIZE][SIZE]) {
    memset(pos, -1, sizeof(pos));
    memset(neg, -1, sizeof(neg));
    for (int i = 0; i < n; i++) lx[i] = *max_element(e[i], e[i] + n);
    fill_n(ly, cnt = n, sum = 0);
    for (int x = 0; x < n; x++) {
      fill(gap, gap + n, int(INF));
      while (1) {
        memset(vx, 0, sizeof(vx));
        memset(vy, 0, sizeof(vy));
        if (aug(x, e)) break;
        int c = *min_element(gap, gap + n);
        for (int i = 0; i < n; i++) {
          if (vx[i]) lx[i] -= c;
          if (vy[i]) ly[i] += c;
        }
      }
    }
    for (int x = 0, y; x < n; x++)
      if (e[x][y = pos[x]] <= -INF)
        cnt--, pos[x] = neg[y] = -1;
      else
        sum += e[x][y];
    return sum;
  }

 private:
  int gap[SIZE], lx[SIZE], ly[SIZE];
  bool vx[SIZE], vy[SIZE];
  bool aug(int x, const int e[SIZE][SIZE]) {
    vx[x] = true;
    for (int y = 0; y < cnt; y++)
      if (!vy[y]) {
        int c = lx[x] + ly[y] - e[x][y];
        if (!c) {
          vy[y] = true;
          gap[y] = INF;
          if (~neg[y] && !aug(neg[y], e)) continue;
          pos[neg[y] = x] = y;
          return true;
        } else {
          if (c < gap[y]) gap[y] = c;
        }
      }
    return false;
  }
} sv;
inline int get(char c) {
  if (islower(c)) return c - 'a';
  return 26 + c - 'A';
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, K;
  cin >> n >> K;
  string s1, s2;
  cin >> s1 >> s2;
  static int C[60][60];
  for (int(i) = 0; (i) < (int)(n); ++(i)) ++C[get(s1[i])][get(s2[i])];
  int res = sv.gao(K, C);
  printf("%d\n", res);
  for (int(i) = 0; (i) < (int)(K); ++(i)) {
    int d = sv.pos[i];
    if (d < 26)
      d = 'a' + d;
    else
      d = 'A' + (d - 26);
    printf("%c", d);
  }
  puts("");
  return 0;
}
