#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int cnt[maxn], n;
char str[maxn];
int main() {
  scanf("%s%d", str, &n);
  int m = strlen(str);
  for (int i = 0; i < m; i++) cnt[str[i] - 'a']++;
  int num = 0;
  for (int i = 0; i < 26; i++)
    if (cnt[i]) num++;
  if (num > n)
    printf("-1\n");
  else {
    int ans = maxn;
    int l = 1, r = maxn;
    while (l <= r) {
      int m = (l + r) >> 1;
      int tmp = 0;
      for (int i = 0; i < 26; i++) {
        if (cnt[i] == 0) continue;
        tmp += cnt[i] / m + (cnt[i] % m > 0);
      }
      if (tmp <= n) {
        ans = m;
        r = m - 1;
      } else
        l = m + 1;
    }
    printf("%d\n", ans);
    int c = 0;
    for (int i = 0; i < 26; i++) {
      if (cnt[i] == 0) continue;
      int tmp = cnt[i] / ans + (cnt[i] % ans > 0);
      c += tmp;
      for (int j = 0; j < tmp; j++) printf("%c", i + 'a');
    }
    c = n - c;
    while (c--) printf("a");
    printf("\n");
  }
  return 0;
}
