#include <bits/stdc++.h>
using namespace std;
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
int ext_gcd(int a, int b, int& x, int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int d = ext_gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
inline long long modInv(int a, int m) {
  int x, y;
  ext_gcd(a, m, x, y);
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
struct node {
  int x, y, next, cap, cost;
};
struct FLOW {
  int source, sink;
  int head[300];
  void clear() {
    e = 0;
    memset(head, -1, sizeof(head));
  }
  node edge[1000000];
  int e;
  void addEdge(int u, int v, int cap, int cost) {
    edge[e].x = u;
    edge[e].y = v;
    edge[e].cap = cap;
    edge[e].cost = cost;
    edge[e].next = head[u];
    head[u] = e;
    e++;
    edge[e].x = v;
    edge[e].y = u;
    edge[e].cap = 0;
    edge[e].cost = -cost;
    edge[e].next = head[v];
    head[v] = e;
    e++;
  }
  int vis[300], q[300], now[300];
  int inq[300], par[300], record[300];
  int minCostFlow(int limit) {
    int res = 0, i, j, k, fl = 0;
    while (1) {
      for (i = 0; i <= limit; i++) vis[i] = -inf;
      vis[source] = 0;
      deque<int> dq;
      dq.push_back(source);
      while (!dq.empty()) {
        int s = dq.front();
        dq.pop_front();
        inq[s] = 0;
        for (i = head[s]; i != -1; i = edge[i].next) {
          int t = edge[i].y;
          if (edge[i].cap) {
            if (vis[s] + edge[i].cost > vis[t]) {
              vis[t] = vis[s] + edge[i].cost;
              par[t] = s;
              record[t] = i;
              if (inq[t] == 0) {
                inq[t] = 1;
                if (dq.empty() == false && vis[dq.front()] < vis[t])
                  dq.push_front(t);
                else
                  dq.push_back(t);
              }
            }
          }
        }
      }
      if (vis[sink] < 0) break;
      fl++;
      res += vis[sink];
      for (i = sink; i != source; i = par[i]) {
        int t = record[i];
        edge[t].cap--;
        edge[t ^ 1].cap++;
      }
    }
    return res;
  }
} graph;
char buf1[2000010], buf2[2000010];
int cost[100][100];
int track[100][100];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  scanf("%s %s", buf1, buf2);
  for (int i = (0); i <= (n - 1); ++i) {
    if (buf1[i] >= 'a' && buf1[i] <= 'z')
      buf1[i] = buf1[i] - 'a' + 1;
    else if (buf1[i] >= 'A' && buf1[i] <= 'Z')
      buf1[i] = buf1[i] - 'A' + 27;
  }
  for (int i = (0); i <= (n - 1); ++i) {
    if (buf2[i] >= 'a' && buf2[i] <= 'z')
      buf2[i] = buf2[i] - 'a' + 1;
    else if (buf2[i] >= 'A' && buf2[i] <= 'Z')
      buf2[i] = buf2[i] - 'A' + 27;
  }
  for (int i = (0); i <= (n - 1); ++i) {
    int u = buf1[i];
    int v = buf2[i];
    cost[u][v]++;
  }
  graph.clear();
  graph.source = 0;
  graph.sink = 105;
  for (int i = (1); i <= (52); ++i) {
    graph.addEdge(0, i, 1, 0);
    graph.addEdge(i + 52, graph.sink, 1, 0);
  }
  for (int i = (1); i <= (k); ++i) {
    for (int j = (1); j <= (k); ++j) {
      track[i][j] = graph.e;
      graph.addEdge(i, 52 + j, 1, cost[i][j]);
    }
  }
  int res = graph.minCostFlow(105);
  printf("%d\n", res);
  for (int i = (1); i <= (k); ++i) {
    for (int j = (1); j <= (k); ++j) {
      int e = track[i][j];
      if (graph.edge[e].cap == 0) {
        int x = j;
        if (x <= 26)
          x = x - 1 + 'a';
        else
          x = x - 26 - 1 + 'A';
        printf("%c", x);
        break;
      }
    }
  }
  puts("");
  return 0;
}
