#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16 + 7;
struct edge {
  long long a, b, c, cost, flow;
  edge() { a = 0, b = 0, c = 0, cost = 0, flow = 0; }
  edge(long long _a, long long _b, long long _c, long long _cost) {
    a = _a, b = _b, c = _c, cost = _cost, flow = 0;
  }
};
vector<edge> e;
vector<vector<long long>> g;
void insert_edge(long long a, long long b, long long c, long long cost) {
  e.push_back(edge(a, b, c, cost));
  g[a].push_back(e.size() - 1);
  e.push_back(edge(b, a, 0, -cost));
  g[b].push_back(e.size() - 1);
}
vector<long long> d, par, phi;
void ford_bellman(long long s) {
  long long n = g.size();
  phi = vector<long long>(n, inf);
  vector<long long> used(n);
  phi[s] = 0;
  queue<long long> q;
  q.push(s);
  used[s] = 1;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    used[u] = 0;
    for (long long id : g[u]) {
      edge& e1 = e[id];
      if (phi[e1.b] > phi[e1.a] + e1.cost && e1.flow < e1.c) {
        phi[e1.b] = phi[e1.a] + e1.cost;
        if (!used[e1.b]) {
          q.push(e1.b);
          used[e1.b] = 1;
        }
      }
    }
  }
}
bool trupoc(long long s, long long t) {
  long long n = g.size();
  d = vector<long long>(n, inf);
  d[s] = 0;
  set<pair<long long, long long>> st;
  st.insert(make_pair(0, s));
  while (!st.empty()) {
    long long u = st.begin()->second;
    long long D = st.begin()->first;
    st.erase(st.begin());
    for (auto id : g[u]) {
      edge& e1 = e[id];
      long long w = phi[e1.a] - phi[e1.b] + e1.cost;
      if (d[u] + w < d[e1.b] && e1.flow < e1.c) {
        d[e1.b] = d[u] + w;
        par[e1.b] = id;
        st.emplace(d[e1.b], e1.b);
      }
    }
  }
  return d[t] != inf;
}
void getans(long long s, long long t) {
  ford_bellman(s);
  while (trupoc(s, t)) {
    d = phi;
    long long minf = inf;
    for (long long v = t; v != s; v = e[par[v]].a) {
      minf = min(minf, e[par[v]].c - e[par[v]].flow);
    }
    for (long long v = t; v != s; v = e[par[v]].a) {
      long long id = par[v];
      e[id].flow += minf;
      e[id ^ 1].flow -= minf;
    }
  }
}
long long getid(char c) {
  if ('a' <= c && c <= 'z') return (c - 'a');
  return (c - 'A' + 26);
}
long long getCh(long long x) {
  if (x < 26) return char('a' + x);
  return char('A' + x - 26);
}
map<pair<long long, long long>, long long> m1;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  long long N = 2 * k + 2;
  g.resize(N);
  par.resize(N);
  phi.resize(N);
  for (long long i = 1; i <= k; ++i) {
    insert_edge(0, i, 1, 0);
    insert_edge(i + k, N - 1, 1, 0);
  }
  string a, b;
  cin >> a >> b;
  vector<long long> deg(k + 1);
  for (long long i = 0; i < n; ++i) {
    m1[{getid(a[i]), getid(b[i])}]++;
    deg[getid(a[i])]++;
  }
  for (long long i = 0; i < k; ++i) {
    for (long long j = 0; j < k; ++j) {
      insert_edge(i + 1, j + k + 1, 1, deg[i] - m1[make_pair(i, j)]);
    }
  }
  getans(0, N - 1);
  long long ans = 0;
  for (auto elem : e) {
    ans += elem.flow * elem.cost;
  }
  cout << n - (ans / 2) << '\n';
  vector<char> answ(k);
  for (auto elem : e) {
    if (1 <= elem.a && elem.a <= k && elem.flow == 1) {
      answ[elem.a - 1] = getCh(elem.b - k - 1);
    }
  }
  for (auto elem : answ) cout << elem;
}
