#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int cnt[256];
bool check(int x) {
  if (x == 0) return false;
  int sum = 0;
  for (char c = 'a'; c <= 'z'; ++c) {
    int d = cnt[c] / x + !!(cnt[c] % x);
    sum += d;
  }
  return sum <= n;
}
string get(int x) {
  string t = "";
  for (char c = 'a'; c <= 'z'; ++c) {
    int d = cnt[c] / x + !!(cnt[c] % x);
    while (d--) t += c;
  }
  while (t.length() < n) t += 'c';
  return t;
}
int main() {
  cin >> s >> n;
  for (int i = 0; i < s.length(); ++i) cnt[s[i]]++;
  int l = 1, r = s.length(), m, ans = -1;
  l = s.length() / n;
  for (m = l; m <= r; ++m) {
    if (check(m)) {
      ans = m;
      break;
    }
  }
  cout << ans << endl;
  if (ans != -1) cout << get(ans) << endl;
  return 0;
}
