#include <bits/stdc++.h>
using namespace std;
int main() {
  char C[1047];
  int n;
  scanf("%s %d", C, &n);
  string s = C;
  vector<int> P, V;
  P.resize(300, 0);
  V.resize(300, 0);
  for (int i = 0; i < (s.length()); i++) P[s[i]]++;
  int poc = 0;
  for (int i = 0; i < (300); i++) {
    if (P[i] == 0) continue;
    V[i]++;
    poc++;
  }
  if (poc > n) {
    printf("-1\n");
    return 0;
  }
  for (int i = 0; i < n - poc; i++) {
    int naj = -1, maxi = -1;
    for (int j = 0; j < (300); j++) {
      if (P[j] == 0) continue;
      int pot = (P[j] + V[j] - 1) / V[j];
      if (pot > maxi) {
        maxi = pot;
        naj = j;
      }
    }
    V[naj]++;
  }
  int maxi = -1;
  for (int i = 0; i < (300); i++) {
    if (P[i] == 0) continue;
    maxi = max(maxi, (P[i] + V[i] - 1) / V[i]);
  }
  printf("%d\n", maxi);
  for (int i = 0; i < (300); i++) {
    for (int j = 0; j < (V[i]); j++) printf("%c", i);
  }
  printf("\n");
  return 0;
}
