#include <bits/stdc++.h>
using namespace std;
ifstream fin("banana.in");
ofstream fout("banana.out");
string s, s2;
int a, b, x, f[30], ct, ok, mx, p, f2[30], q[30];
int main() {
  int i;
  cin >> s;
  cin >> x;
  for (i = 0; i < s.size(); i++) {
    if (f[s[i] - 'a'] == 0) ct++;
    f[s[i] - 'a']++;
  }
  if (ct > x)
    cout << -1;
  else {
    ok = 1;
    ct = 0;
    for (i = 0; i < 26; i++) {
      f2[i] = f[i];
      if (f[i] > 0) {
        s2 += char(i + 'a');
        q[i]++;
        ct++;
        x--;
      }
    }
    while (ok == 1 && x) {
      ok = 0;
      mx = 0;
      for (i = 0; i < 26; i++) {
        if (f[i] > 0) ok = 1;
        if (q[i] > 0 && mx < (f[i] - 1) / q[i]) {
          p = i;
          mx = (f[i] - 1) / q[i];
        }
      }
      if (ok == 1) {
        s2 += char(p + 'a');
        q[p]++;
        ct++;
      }
      x--;
    }
    mx = 0;
    for (i = 0; i < 26; i++)
      if (q[i] > 0) mx = max(mx, (f2[i] - 1) / q[i] + 1);
    cout << mx << endl;
    cout << s2;
  }
}
