#include <bits/stdc++.h>
using namespace std;
inline int intceil(int a, int b) {
  if (a % b) return a / b + 1;
  return a / b;
}
int main() {
  string s;
  int n, min_l = 0;
  cin >> s >> n;
  vector<int> frecv(26, 0), sol(26, 0);
  for (auto &&ch : s) {
    if (frecv[ch - 'a'] == 0) {
      min_l++;
      sol[ch - 'a'] = 1;
    }
    frecv[ch - 'a']++;
  }
  if (min_l > n) {
    cout << "-1\n";
    return 0;
  }
  n -= min_l;
  int maxid, maxval;
  while (n > 0) {
    maxid = -1;
    maxval = -1;
    for (int i = 0; i < 26; i++) {
      if (sol[i])
        if (intceil(frecv[i], sol[i]) > maxval) {
          maxval = intceil(frecv[i], sol[i]);
          maxid = i;
        }
    }
    sol[maxid]++;
    n--;
  }
  maxval = -1;
  for (int i = 0; i < 26; i++) {
    if (sol[i])
      if (intceil(frecv[i], sol[i]) > maxval) {
        maxval = intceil(frecv[i], sol[i]);
      }
  }
  cout << maxval << '\n';
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < sol[i]; j++) cout << static_cast<char>(i + 'a');
  }
  return 0;
}
