#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, fr[60];
  char s[1010];
  while (scanf(" %s %d", s, &n) == 2) {
    memset(fr, 0, sizeof(fr));
    for (int i = 0; s[i]; i++) fr[s[i] - 'a']++;
    int res = -1;
    for (int qs = 1; qs <= 1000; qs++) {
      int us = 0;
      for (int i = 0; i < 26; i++) us += (fr[i] + qs - 1) / qs;
      if (us <= n) {
        res = qs;
        break;
      }
    }
    printf("%d\n", res);
    if (res != -1) {
      int prn = 0;
      for (int i = 0; i < 26; i++)
        for (int k = 0; k < (fr[i] + res - 1) / res; k++) {
          prn++;
          printf("%c", i + 'a');
        }
      for (int i = 0; i < n - prn; i++) printf("a");
      printf("\n");
    }
  }
  return 0;
}
