#include <bits/stdc++.h>
using namespace std;
int am[27];
int dp[27][1010];
int path[27][1010];
int call(int p, int n) {
  if (p == 26) return (n == 0 ? 0 : (1 << 29));
  int &ret = dp[p][n];
  if (ret != -1) return ret;
  int &ppp = path[p][n];
  ret = (1 << 29);
  if (!am[p]) {
    ret = call(p + 1, n);
    ppp = 0;
  }
  for (int i = 1; i <= n; i++) {
    int temp = max(call(p + 1, n - i), am[p] / i + bool(am[p] % i));
    if (ret > temp) ret = temp, ppp = i;
  }
  return ret;
}
int main() {
  string s;
  int n;
  cin >> s >> n;
  for (__typeof(((int)s.size())) i = 0; i < (((int)s.size())); i++)
    am[s[i] - 'a']++;
  memset((dp), (-1), sizeof(dp));
  ;
  if (call(0, n) >= (1 << 29)) {
    cout << -1 << endl;
    return 0;
  }
  int aa = 0, bb = n;
  cout << call(0, n) << endl;
  while (aa < 26) {
    int am = path[aa][bb];
    for (__typeof(am) i = 0; i < (am); i++) cout << char(aa + 'a');
    aa++;
    bb -= am;
  }
  cout << endl;
  return 0;
}
