#include <bits/stdc++.h>
using namespace std;
int Hash[28];
int main() {
  string input;
  cin >> input;
  int n;
  cin >> n;
  for (int i = 0; input[i]; i++) Hash[input[i] - 'a']++;
  for (int i = 1; i <= 1000; i++) {
    string result;
    int itr = 1;
    for (int j = 0; j < 26; j++) {
      int k = Hash[j] / i + bool(Hash[j] % i);
      while (k) {
        result += j + 'a';
        k--;
        itr++;
      }
    }
    itr--;
    if (itr <= n) {
      while (itr < n) {
        itr++;
        result += 'a';
      }
      cout << i << endl;
      cout << result << endl;
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}
