#include <bits/stdc++.h>
using namespace std;
int cnt[28];
int main() {
  string s;
  int n, tot, len;
  cin >> s >> n;
  len = s.size();
  for (int i = 0; i < len; ++i) ++cnt[s[i] - 'a'];
  int l = 1, r = len + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    int need = 0;
    for (int i = 0; i < 28; ++i) need += (cnt[i] + mid - 1) / mid;
    if (need <= n)
      r = mid;
    else
      l = mid + 1;
  }
  if (l == len + 1) {
    puts("-1");
    return 0;
  } else {
    tot = 0;
    printf("%d\n", l);
    for (int i = 0; i < 28; ++i) {
      for (int j = 1; j <= (cnt[i] + l - 1) / l; ++j) {
        printf("%c", 'a' + i);
        ++tot;
      }
    }
    while (tot < n) {
      putchar('a');
      ++tot;
    }
    printf("\n");
  }
  return 0;
}
