#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1e9 + 1;
const long double EPS = 1e-9;
const int maxl = (int)1e3 + 10;
char s[maxl];
const int maxc = 26;
int cnt[maxc];
bool solve() {
  int n;
  if (scanf("%s%d", s, &n) < 2) return 0;
  int len = strlen(s);
  for (int i = 0; i < maxc; ++i) {
    cnt[i] = 0;
  }
  for (int i = 0; i < len; ++i) {
    cnt[s[i] - 'a'] += 1;
  }
  int l = 0, r = len + 1;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    int sum = 0;
    for (int i = 0; i < maxc; ++i) {
      sum += (cnt[i] + m - 1) / m;
    }
    if (sum > n)
      l = m;
    else
      r = m;
  }
  if (r <= len) {
    printf("%d\n", r);
    int left = n;
    for (int i = 0; i < maxc; ++i) {
      int cur = (cnt[i] + r - 1) / r;
      left -= cur;
      for (int j = 0; j < cur; ++j) printf("%c", 'a' + i);
    }
    assert(left >= 0);
    while (left > 0) {
      printf("a");
      --left;
    }
    printf("\n");
  } else
    printf("-1\n");
  return 1;
}
int main() {
  srand(rdtsc());
  while (1) {
    if (!solve()) break;
  }
  return 0;
}
