#include <bits/stdc++.h>
using namespace std;
char s[1024];
int n;
int cnt[26], kind;
int mem[26];
char res[1024];
bool chk(int sz) {
  for (int i = 0; i < 26; i++) mem[i] = cnt[i];
  int ch = 0;
  for (int i = 0; i < n; i++) {
    while (ch < 26 && mem[ch] <= 0) ch++;
    if (ch == 26)
      res[i] = 'z';
    else {
      res[i] = ch + 'a';
      mem[ch] -= sz;
    }
  }
  for (int i = 0; i < 26; i++)
    if (mem[i] > 0) return false;
  return true;
}
int main() {
  scanf("%s", s);
  scanf("%d", &n);
  for (int i = 0; i < 26; i++) cnt[i] = 0;
  for (int i = 0; s[i]; i++) cnt[s[i] - 'a']++;
  kind = 0;
  for (int i = 0; i < 26; i++)
    if (cnt[i]) kind++;
  if (kind > n)
    printf("-1\n");
  else {
    int lb = 1, ub = strlen(s);
    while (lb < ub) {
      int md = lb + (ub - lb) / 2;
      if (chk(md))
        ub = md;
      else
        lb = md + 1;
    }
    printf("%d\n", lb);
    chk(lb);
    printf("%s\n", res);
  }
  return 0;
}
