#include <bits/stdc++.h>
using namespace std;
long get(char c) { return ('a' <= c && c <= 'z') ? c - 'a' + 1 : c - 'A' + 27; }
long N, M;
long ANS, ans[1 << 20];
int main() {
  vector<long> u(1 << 20);
  vector<long> v(1 << 20);
  vector<long> p(1 << 20);
  vector<long> way(1 << 20);
  vector<vector<long>> a(1 << 10, vector<long>(1 << 10));
  long n, k;
  string st1, st2;
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  cin >> st1 >> st2;
  for (int i = 0; i < st1.size(); i++) {
    a[get(st1[i])][get(st2[i])]--;
  }
  N = M = k;
  for (int i = 1; i <= N; i++) {
    p[0] = i;
    long j0 = 0;
    vector<long> minv(M + 1, 1e9);
    vector<long> used(M + 1, 0);
    do {
      used[j0] = 1;
      long i0, delta, j1;
      i0 = p[j0];
      delta = 1e9;
      for (int j = 1; j <= M; j++) {
        if (used[j]) continue;
        long cur = a[i0][j] - u[i0] - v[j];
        if (cur < minv[j]) minv[j] = cur, way[j] = j0;
        if (minv[j] < delta) delta = minv[j], j1 = j;
      }
      for (int j = 0; j <= M; j++)
        if (used[j])
          u[p[j]] += delta, v[j] -= delta;
        else
          minv[j] -= delta;
      j0 = j1;
    } while (p[j0] != 0);
    do {
      long j1 = way[j0];
      p[j0] = p[j1];
      j0 = j1;
    } while (j0);
  }
  for (int i = 1; i <= M; i++) ans[p[i]] = i;
  for (int i = 1; i <= M; i++) ANS -= a[i][ans[i]];
  cout << ANS << endl;
  for (int i = 1; i <= M; i++) {
    int t = ans[i];
    if (t <= 26)
      cout << char(t + 'a' - 1);
    else
      cout << char(t + 'A' - 27);
  }
  cout << endl;
  cin.get();
  cin.get();
  return 0;
}
