#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int lettersNumbersShowed[1000];
int lettersInserted[1000];
int letters[1000];
int greedyChoice[1000];
int main(int argc, const char* argv[]) {
  string str;
  string fullAns;
  cin >> str;
  int n;
  scanf(" %d", &n);
  string ans;
  int timesLetterAppears = 0;
  int k = 1;
  std::sort(str.begin(), str.end());
  char previous = str[0];
  for (int i = 0; i < str.length(); i++) {
    char c = str[i];
    if (i == 0) {
      ans[0] = str[i];
    }
    if (c != previous) {
      lettersNumbersShowed[k - 1] = timesLetterAppears;
      letters[k - 1] = previous;
      lettersInserted[k - 1] = 1;
      greedyChoice[k - 1] = timesLetterAppears;
      timesLetterAppears = 1;
      ans[k] = str[i];
      k++;
    } else {
      timesLetterAppears++;
    }
    str[i] = c;
    previous = c;
  }
  lettersNumbersShowed[k - 1] = timesLetterAppears;
  letters[k - 1] = previous;
  lettersInserted[k - 1] = 1;
  greedyChoice[k - 1] = timesLetterAppears;
  if (n >= k) {
    int a = n;
    int j = k;
    for (int i = 0; i < n - k; i++) {
      a = -200000000;
      int index;
      for (int i = 0; i < k; i++) {
        if (greedyChoice[i] > a) {
          a = greedyChoice[i];
          index = i;
        }
      }
      ans[j] = letters[index];
      j++;
      lettersInserted[index]++;
      greedyChoice[index] =
          ceil((float)lettersNumbersShowed[index] / lettersInserted[index]);
    }
    a = -200000000;
    int index;
    for (int i = 0; i < k; i++) {
      if (greedyChoice[i] > a) {
        a = greedyChoice[i];
        index = i;
      }
    }
    a = greedyChoice[index];
    printf("%d\n", a);
    for (int i = 0; i < n; i++) {
      printf("%c", ans[i]);
    }
  } else {
    printf("-1");
  }
  printf("\n");
  return 0;
}
