#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
char letters[30];
int numbers[30];
int mystring[30];
int ceiling(int top, int bottom) { return (top + bottom - 1) / bottom; }
int main() {
  string s;
  int n;
  cin >> s >> n;
  for (int i = 0; i < (int)s.length(); i++) m[s[i]]++;
  int numChar = 0;
  for (map<char, int>::iterator it = m.begin(); it != m.end(); ++it) {
    letters[numChar] = it->first;
    numbers[numChar] = it->second;
    numChar++;
  }
  if (numChar > n) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < numChar; i++) mystring[i] = 1;
  for (int i = numChar; i < n; i++) {
    int needMost = -1, needMostIndex = -1;
    for (int j = 0; j < numChar; j++) {
      if (ceiling(numbers[j], mystring[j]) > needMost) {
        needMost = ceiling(numbers[j], mystring[j]);
        needMostIndex = j;
      }
    }
    mystring[needMostIndex]++;
  }
  int needMost = -1;
  for (int j = 0; j < numChar; j++) {
    if (ceiling(numbers[j], mystring[j]) > needMost) {
      needMost = ceiling(numbers[j], mystring[j]);
    }
  }
  cout << needMost << endl;
  for (int i = 0; i < numChar; i++)
    for (int j = 0; j < mystring[i]; j++) cout << letters[i];
  cout << endl;
  return 0;
}
