#include <bits/stdc++.h>
using namespace std;
bool solved[26][1003];
char s[1003];
int C[26], M[26][1003], P[26][1003];
int DP(int i, int j) {
  if (i == 26) return 0;
  if (solved[i][j]) return M[i][j];
  solved[i][j] = true;
  if (!C[i]) return M[i][j] = DP(i + 1, j);
  M[i][j] = 2147483647;
  for (int k = 1, r; k <= C[i] && k <= j; ++k) {
    r = max((C[i] + k - 1) / k, DP(i + 1, j - k));
    if (M[i][j] > r) M[i][j] = r, P[i][j] = k;
  }
  return M[i][j];
}
int print_soln(int i, int j) {
  if (i < 26) {
    for (int k = 0; k < P[i][j]; ++k) putchar('a' + i);
    return P[i][j] + print_soln(i + 1, j - P[i][j]);
  }
  return 0;
}
void solve(int n) {
  int soln, i;
  for (i = 0; s[i]; ++i) C[s[i] - 'a']++;
  soln = DP(0, n);
  if (soln < 2147483647) {
    int c;
    printf("%d\n", soln);
    c = print_soln(0, n);
    for (i = c; i < n; ++i) putchar('a');
  } else
    puts("-1");
}
int main() {
  int n;
  scanf("%s %d", s, &n);
  solve(n);
  return 0;
}
