#include <bits/stdc++.h>
using namespace std;
int n, cnt[26], k, dif;
char s[2000];
bool u[26];
bool ok(int kk) {
  int need_n = 0;
  for (int i = 0; i < 26; i++) need_n += (cnt[i] + kk - 1) / kk;
  return (need_n <= n);
}
int main() {
  scanf("%s", s);
  scanf("%d", &n);
  dif = 0;
  for (int i = 0; s[i]; i++) {
    cnt[(int)(s[i] - 'a')]++;
    if (!u[(int)(s[i] - 'a')]) {
      u[(int)(s[i] - 'a')] = true;
      dif++;
    }
  }
  if (dif > n) {
    printf("-1\n");
    return 0;
  }
  k = 1;
  while (1) {
    if (ok(k)) break;
    k++;
  }
  printf("%d\n", k);
  int left = n;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < (int)((cnt[i] + k - 1) / k); j++)
      printf("%c", (char)('a' + i));
    left -= (cnt[i] + k - 1) / k;
  }
  for (int i = 0; i < left; i++) printf("z");
  printf("\n");
  return 0;
}
