#include <bits/stdc++.h>
using namespace std;
struct lett {
  char let;
  int nb;
  int at;
};
int main() {
  int values[26], offset = static_cast<int>('a'), total;
  lett letts[26];
  string str;
  cin >> str;
  for (int i = 0; i < 26; i++) {
    values[i] = 0;
  }
  for (int i = 0; i < str.length(); i++) {
    values[static_cast<int>(str.at(i) - offset)]++;
  }
  int total_nb = 0;
  for (int i = 0; i < 26; i++) {
    if (values[i] > 0) {
      total_nb++;
      letts[total_nb - 1].let = static_cast<char>(offset + i);
      letts[total_nb - 1].nb = values[i];
      letts[total_nb - 1].at = 1;
    }
  }
  string final = "";
  cin >> total;
  if (total < total_nb) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < total_nb; i++) {
    final += letts[i].let;
    total--;
  }
  while (total > 0) {
    int id = 0;
    for (int i = 0; i < total_nb; i++) {
      if (letts[i].nb / (letts[i].at + 0.0) >
          letts[id].nb / (letts[id].at + 0.0))
        id = i;
    }
    final += letts[id].let;
    letts[id].at += 1;
    total--;
  }
  int fin_id = 0;
  for (int i = 0; i < total_nb; i++) {
    if (letts[i].nb / (letts[i].at + 0.0) >
        letts[fin_id].nb / (letts[fin_id].at + 0.0))
      fin_id = i;
  }
  if ((letts[fin_id].nb) % letts[fin_id].at == 0)
    cout << (letts[fin_id].nb) / letts[fin_id].at;
  else
    cout << (letts[fin_id].nb) / letts[fin_id].at + 1;
  cout << endl;
  cout << final;
  return 0;
}
