#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {-1, 0, 0, 1, 0, -1, 1, 0};
char s[1010];
int cnt[30] = {0};
int n;
bool can(int mid) {
  int k = 0;
  for (int i = 0; i < 26; i++) {
    if (cnt[i] == 0) continue;
    int t = cnt[i] - mid;
    if (t > 0) {
      k += (t + mid - 1) / mid;
    }
  }
  return k <= n;
}
int main() {
  int nn;
  scanf("%s", s);
  scanf("%d", &n);
  for (int i = 0; s[i]; i++) {
    cnt[s[i] - 'a']++;
  }
  nn = n;
  for (int i = 0; i < 26; i++)
    if (cnt[i]) n--;
  if (n < 0) {
    puts("-1");
    return 0;
  }
  int l = 1, r = 1000, ans;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (can(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d\n", ans);
  string res = "";
  for (int i = 0; i < 26; i++) {
    if (cnt[i] == 0) continue;
    int t = cnt[i] - ans;
    res += (char)(i + 'a');
    if (t <= 0) continue;
    int k = t / ans;
    if (t % ans) k++;
    while (k--) res += (char)(i + 'a');
  }
  while (res.length() < nn) res += 'a';
  cout << res << endl;
  return 0;
}
