#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1100, Maxm = 101;
char str[Maxn];
int cnt[Maxm];
int n, m;
bool check(int vtimes) {
  int sum = 0;
  for (int i = 0; i < (26); ++i)
    sum += cnt[i] / vtimes + (cnt[i] % vtimes != 0);
  return sum <= m;
}
int bSearch() {
  int l = 1, r = n, res = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      res = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return res;
}
void myoutput(int vtimes) {
  int tmp = 0;
  for (int i = 0; i < (26); ++i) {
    int len = cnt[i] / vtimes + (cnt[i] % vtimes != 0);
    for (int j = 0; j < (len); ++j) printf("%c", i + 'a'), tmp++;
  }
  for (int i = (tmp); i < (m); i++) printf("f");
  puts("");
}
int main() {
  while (~scanf("%s", str)) {
    scanf("%d", &m);
    memset(cnt, 0, sizeof(cnt));
    n = strlen(str);
    for (int i = 0; i < (n); ++i) cnt[str[i] - 'a']++;
    int res = bSearch();
    printf("%d\n", res);
    if (res != -1) myoutput(res);
  }
  return 0;
}
