#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n, kind, cnt[30];
char str[maxn];
int need[30], tot;
bool check(int mid) {
  memset(need, 0, sizeof need);
  tot = 0;
  for (int i = 0; i < 26; ++i) {
    need[i] = ceil(double(cnt[i]) / double(mid));
    tot += need[i];
    if (tot > n) return false;
  }
  return true;
}
int binary(int left, int rght) {
  while (left < rght) {
    int mid = (left + rght) >> 1;
    if (check(mid))
      rght = mid;
    else
      left = mid + 1;
  }
  check(rght);
  return rght;
}
int main() {
  scanf("%s", str);
  scanf("%d", &n);
  for (int i = 0; str[i]; ++i) ++cnt[str[i] - 'a'];
  for (int i = 0; i < 26; ++i)
    if (cnt[i]) ++kind;
  if (n < kind) {
    puts("-1");
    return 0;
  }
  int ans = binary(1, 1e3);
  printf("%d\n", ans);
  for (int i = 0; i < 26; ++i)
    while (need[i]--) putchar('a' + i), --n;
  while (n) putchar('a'), --n;
  puts("");
  return 0;
}
