#include <bits/stdc++.h>
using namespace std;
char s[2000];
int n;
map<char, int> counter;
map<char, int> repeat;
int main() {
  scanf("%s", s);
  scanf("%d", &n);
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    counter[s[i]] += 1;
    repeat[s[i]] = 1;
  }
  if (n < counter.size()) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n - counter.size(); i++) {
    int maxv = 0;
    char maxk;
    for (map<char, int>::iterator it = counter.begin(); it != counter.end();
         it++) {
      int h = ceil((double)it->second / repeat[it->first]);
      if (h > maxv) {
        maxv = h;
        maxk = it->first;
      }
    }
    repeat[maxk]++;
  }
  int maxh = 0;
  char res[2000] = "";
  for (map<char, int>::iterator it = counter.begin(); it != counter.end();
       it++) {
    int h = ceil((double)it->second / repeat[it->first]);
    if (h > maxh) {
      maxh = h;
    }
    for (int i = 0; i < repeat[it->first]; i++)
      sprintf(res + strlen(res), "%c", it->first);
  }
  printf("%d\n", maxh);
  printf("%s\n", res);
}
