#include <bits/stdc++.h>
char s[1010];
char ans[1010];
int n;
int a[26];
int main() {
  scanf("%s", s);
  scanf("%d", &n);
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    a[s[i] - 'a']++;
  }
  int char_count = 0;
  for (int i = 0; i < 26; i++) {
    if (a[i] > 0) char_count++;
  }
  if (char_count > n) {
    printf("-1\n");
    return 0;
  }
  int sum = 0;
  int p = 0;
  do {
    p++;
    sum = 0;
    for (int i = 0; i < 26; i++) {
      sum += a[i] / p + (a[i] % p > 0);
    }
  } while (sum > n);
  int pa = 0;
  for (int i = 0; i < 26; i++) {
    while (a[i] > 0) {
      a[i] -= p;
      ans[pa++] = 'a' + i;
    }
  }
  while (pa < n) {
    ans[pa++] = 'a';
  }
  ans[n] = 0;
  printf("%d\n%s\n", p, ans);
  return 0;
}
