#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, k, v[30];
string s;
int main() {
  cin >> s >> n;
  for (i = 0; i < s.size(); i++) v[s[i] - 'a']++;
  for (k = 1; k <= s.size(); k++) {
    m = 0;
    for (i = 0; i < 26; i++) m += ceil(v[i] / (double)k);
    if (m <= n) {
      cout << k << "\n";
      for (i = 0; i < 26; i++)
        for (j = 1; j <= ceil(v[i] / (double)k); j++) cout << (char)('a' + i);
      for (i = m; i < n; i++) cout << 'a';
      break;
    }
  }
  if (k > s.size()) cout << -1;
}
