#include <bits/stdc++.h>
using namespace std;
void min_stickers(string s, int k) {
  int n = s.length();
  vector<int> count(26, 0);
  vector<int> a(26, 0);
  for (int i = 0; i < n; i++) {
    count[s[i] - 'a']++;
    a[s[i] - 'a'] = 1;
  }
  int temp = 0;
  for (int i = 0; i < 26; i++)
    if (a[i]) temp++;
  if (temp > k) {
    printf("-1\n");
    return;
  }
  int diff = k - temp;
  while (diff) {
    int idx;
    int maxi = 0;
    for (int i = 0; i < 26; i++) {
      if (a[i] && ceil(float(count[i]) / float(a[i])) > maxi) {
        maxi = ceil(float(count[i]) / float(a[i]));
        idx = i;
      }
    }
    a[idx]++;
    diff--;
  }
  int ans = -1;
  string t;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < a[i]; j++) t += ('a' + i);
    if (a[i] && ceil(float(count[i]) / float(a[i])) > ans)
      ans = ceil(float(count[i]) / float(a[i]));
  }
  cout << ans << "\n";
  cout << t << "\n";
}
int main() {
  int k;
  string s;
  cin >> s;
  cin >> k;
  min_stickers(s, k);
  return 0;
}
