#include <bits/stdc++.h>
using namespace std;
const int force = 27;
const int inf = 1000 * 1000 * 1000;
string s;
int n, a[force], b[force];
int main() {
  cin >> s;
  cin >> n;
  for (int i = 0; i < force; i++) {
    a[i] = 0;
    b[i] = 0;
  }
  int dif = 0;
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    a[int(s[i]) - int('a')]++;
    if (a[int(s[i]) - int('a')] == 1) {
      dif++;
      ans += s[i];
      b[int(s[i]) - int('a')] = 1;
    }
  }
  if (dif > n) {
    cout << -1;
    return 0;
  }
  int ind, maxcnt, mod;
  while (n > int(ans.length())) {
    maxcnt = -1;
    for (int i = 0; i < force; i++) {
      if (a[i] != 0) {
        mod = 0;
        if (a[i] % b[i] > 0) mod++;
        if (maxcnt < a[i] / b[i] + mod) {
          maxcnt = a[i] / b[i] + mod;
          ind = i;
        }
      }
    }
    ans += char(ind + int('a'));
    b[ind]++;
  }
  maxcnt = -1;
  for (int i = 0; i < force; i++) {
    if (a[i] != 0) {
      mod = 0;
      if (a[i] % b[i] > 0) mod++;
      maxcnt = max(maxcnt, a[i] / b[i] + mod);
    }
  }
  cout << maxcnt << '\n';
  cout << ans;
  return 0;
}
