#include <bits/stdc++.h>
using namespace std;
char kata[1005];
int panjang, total[30], batas;
int main() {
  scanf("%s", kata);
  panjang = strlen(kata);
  for (int i = 0; i < panjang; ++i) ++total[kata[i] - 'a'];
  scanf("%d", &batas);
  int cek = 0;
  for (int i = 0; i < 26; ++i)
    if (total[i]) ++cek;
  if (cek > batas) {
    printf("-1\n");
    return 0;
  }
  int kiri = 0;
  int kanan = panjang;
  while (kanan - kiri > 1) {
    int tengah = (kanan + kiri) / 2;
    int pakai = 0;
    for (int i = 0; i < 26; ++i) {
      pakai += (total[i] + tengah - 1) / tengah;
    }
    if (pakai > batas)
      kiri = tengah;
    else
      kanan = tengah;
  }
  printf("%d\n", kanan);
  for (int i = 0; i < 26; ++i) {
    int temp = (total[i] + kanan - 1) / kanan;
    for (int j = 0; j < temp; ++j) printf("%c", i + 'a');
    batas -= temp;
  }
  for (int i = 0; i < batas; ++i) printf("a");
  printf("\n");
  return 0;
}
