#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
char str[1010];
int a[30];
int n;
bool can(int x) {
  int y = 0;
  for (int i = 0; i < 26; i++) y += a[i] / x + (a[i] % x > 0);
  if (y <= n) return true;
  return false;
}
int main() {
  scanf("%s", str);
  for (int i = 0; str[i]; i++) a[str[i] - 'a']++;
  scanf("%d", &n);
  int l = 1, r = 1000;
  while (l <= r) {
    int mid = l + r >> 1;
    if (can(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (l == 1001)
    puts("-1");
  else {
    int L = 0;
    printf("%d\n", l);
    for (int i = 0; i < 26; i++) {
      int len = a[i] / l + (a[i] % l > 0);
      for (int j = 0; j < len; j++) printf("%c", i + 'a');
      L += len;
    }
    for (int j = L; L < n; L++) printf("a");
  }
  return 0;
}
