#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[1001];
int main() {
  scanf("%s%d", s, &n);
  m = strlen(s);
  vector<int> c(26, 0);
  for (int i = 0; i < m; ++i) {
    c[s[i] - 'a'] += 1;
  }
  m = 0;
  for (int i = 0; i < 26; ++i) {
    if (c[i] > 0) {
      m += 1;
    }
  }
  if (m > n) {
    printf("-1\n");
    return 0;
  }
  int pl = 0, pr = 10000;
  while (pl + 1 < pr) {
    int pm = pl + (pr - pl) / 2;
    int count = 0;
    for (auto i : c) {
      count += (i + pm - 1) / pm;
    }
    (count <= n ? pr : pl) = pm;
  }
  string res = "";
  for (int i = 0; i < 26; ++i) {
    int count = (c[i] + pr - 1) / pr;
    res += string(count, 'a' + i);
  }
  while ((int)res.length() < n) {
    res += 'z';
  }
  printf("%d\n", pr);
  printf("%s\n", res.c_str());
  return 0;
}
