#include <bits/stdc++.h>
using namespace std;
char a[1005];
int t[26] = {0};
int func(int m) {
  int c = 0, i;
  for (i = 0; i < 26; i++) {
    if (t[i] != 0) {
      if (t[i] % m == 0)
        c += (t[i] / m);
      else
        c += (t[i] / m + 1);
    }
  }
  return c;
}
int main() {
  int s, n, i, j, c = 0, e, mid, l = 0;
  for (i = 0; i < 26; i++) t[i] = 0;
  scanf("%s", a);
  cin >> n;
  for (i = 0; a[i] != '\0'; i++) {
    l++;
    if (t[a[i] - 'a'] == 0) c++;
    t[a[i] - 'a']++;
  }
  if (c > n) {
    cout << -1 << endl;
    return 0;
  }
  s = 1;
  e = l;
  int f = 0;
  while (s <= e) {
    mid = s + (e - s) / 2;
    j = func(mid);
    if (f == 1) break;
    if (j <= n)
      e = mid;
    else
      s = mid + 1;
    if (s == e) f = 1;
  }
  cout << mid << endl;
  s = mid;
  int r = 0;
  for (i = 0; i < 26; i++) {
    c = 0;
    if (t[i] % s == 0)
      c = (t[i] / s);
    else
      c = (t[i] / s + 1);
    r += c;
    for (j = 0; j < c; j++) {
      cout << (char)(97 + i);
    }
    t[i] -= c;
  }
  i = 0;
  while (r < n) {
    r++;
    cout << (char)(97 + i);
  }
  cout << endl;
  return 0;
}
