#include <bits/stdc++.h>
using namespace std;
const int MAX = 60;
template <int SZ>
struct MCMF {
  int N = 0, s, t;
  struct Edge {
    int to, rev;
    int flow, cap;
    int cost;
    int id;
  };
  vector<Edge> adj[SZ];
  void addEdge(int u, int v, int cap, int cost, int id = 0) {
    N = max(N, max(u, v) + 1);
    Edge a = {v, (int)adj[v].size(), 0, cap, cost, id},
         b = {u, (int)adj[u].size(), 0, 0, -cost, 0};
    adj[u].push_back(a), adj[v].push_back(b);
  }
  pair<int, int> pre[SZ];
  pair<int, int> cost[SZ];
  int totCost = 0, curCost = 0;
  int totFlow = 0;
  bool SPFA() {
    for (int i = 0; i < SZ; i++) cost[i] = {numeric_limits<int>::max(), 0};
    cost[s] = {0, numeric_limits<int>::max()};
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        pq;
    pq.push({0, s});
    while (!pq.empty()) {
      pair<int, int> cur = pq.top();
      pq.pop();
      if (cur.first > cost[cur.second].first) continue;
      for (auto &e : adj[cur.second]) {
        if (e.flow == e.cap) continue;
        if (cost[e.to].first > cur.first + e.cost) {
          cost[e.to] = {cur.first + e.cost,
                        min(e.cap - e.flow, cost[cur.second].second)};
          pre[e.to] = {cur.second, e.rev};
          pq.push({cost[e.to].first, e.to});
        }
      }
    }
    return cost[t].second;
  }
  void backTrack() {
    int df = cost[t].second;
    totFlow += df;
    curCost += cost[t].first;
    totCost += curCost * df;
    for (int u = t; u != s; u = pre[u].first) {
      adj[u][pre[u].second].flow -= df;
      adj[pre[u].first][adj[u][pre[u].second].rev].flow += df;
    }
    for (int i = 0; i < SZ; i++)
      for (auto &e : adj[i]) e.cost += cost[i].first - cost[e.to].first;
  }
  pair<int, int> calc(int _s, int _t) {
    s = _s, t = _t;
    while (SPFA()) backTrack();
    return {totFlow, totCost};
  }
};
int cnt[MAX][MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  string a, b;
  cin >> a >> b;
  map<char, int> key;
  map<int, char> val;
  for (int i = 1; i <= k; i++) {
    if (i <= 26) {
      key[char('a' + i - 1)] = i;
      val[i] = char('a' + i - 1);
    } else {
      key[char('A' + i - 27)] = i;
      val[i] = char('A' + i - 27);
    }
  }
  for (int i = 0; i < n; i++) cnt[key[a[i]]][key[b[i]]]++;
  MCMF<2 * MAX> Network;
  int s = 0, t = 2 * k + 1;
  for (int i = 1; i <= k; i++) {
    Network.addEdge(s, i, 1, 0);
    Network.addEdge(k + i, t, 1, 0);
    for (int j = 1; j <= k; j++) Network.addEdge(i, k + j, 1, -cnt[i][j], j);
  }
  cout << Network.calc(s, t).second * -1 << "\n";
  for (int i = 1; i <= k; i++) {
    for (auto &e : Network.adj[i]) {
      if (e.flow == 1) cout << val[e.id];
    }
  }
  return 0;
}
