#include <bits/stdc++.h>
using namespace std;
string s;
int num[1500];
int lets;
int n, len;
int l, r, m;
bool ok(int x) {
  int cur = 0;
  for (char c = 'a'; c <= 'z'; c++)
    if (num[c] > 0) {
      if (num[c] % x == 0)
        cur += num[c] / x;
      else
        cur += (num[c] / x) + 1;
    }
  if (cur > n)
    return false;
  else
    return true;
}
int main() {
  getline(cin, s);
  scanf("%d", &n);
  len = (int)s.length();
  for (int i = 0; i < len; i++) {
    if (num[s[i]] == 0) lets++;
    num[s[i]]++;
  }
  if (lets > n) {
    printf("-1");
    return 0;
  }
  l = 1;
  r = 1000;
  while (l < r) {
    m = (l + r) / 2;
    if (ok(m))
      r = m;
    else
      l = m + 1;
  }
  printf("%d\n", l);
  int cur = 0;
  for (char c = 'a'; c <= 'z'; c++)
    if (num[c] > 0) {
      int add = 0;
      if (num[c] % l == 0)
        add = num[c] / l;
      else
        add = (num[c] / l) + 1;
      cur += add;
      for (int j = 0; j < add; j++) printf("%c", c);
    }
  while (cur < n) {
    printf("a");
    cur++;
  }
  return 0;
}
