#include <bits/stdc++.h>
using namespace std;
char str[1005];
int N;
int cword[30];
int main() {
  scanf("%s", str);
  scanf("%d", &N);
  int i;
  int type = 0;
  for (i = 0; str[i] != '\0'; i++) {
    if (cword[(int)(str[i] - 'a' + 1)] == 0) type++;
    cword[(int)(str[i] - 'a' + 1)]++;
  }
  if (N < type)
    printf("-1\n");
  else {
    int st = 1, ed = i - 1;
    while (st <= ed) {
      int Sum = 0;
      int mid = (st + ed) / 2;
      for (int i = 1; i <= 26; i++) {
        Sum += (cword[i] + mid - 1) / mid;
      }
      if (Sum > N) {
        st = mid + 1;
      } else {
        ed = mid - 1;
      }
    }
    int ans = ed + 1;
    int print = 0;
    printf("%d\n", ans);
    for (int i = 1; i <= 26; i++) {
      int k = (cword[i] + ans - 1) / ans;
      for (int j = 1; j <= k; j++) {
        printf("%c", i + 'a' - 1);
        print++;
      }
    }
    while (print < N) {
      printf("a");
      print++;
    }
    printf("\n");
  }
}
