#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  int a[26], ans[26];
  for (int i = 0; i < 26; i++) {
    a[i] = 0;
    ans[i] = 0;
  }
  for (int i = 0; i < s.length(); i++) a[s[i] - 'a']++;
  for (int i = 0; i < 26; i++) {
    if (a[i] != 0) {
      a[i]--;
      ans[i]++;
      n--;
    }
  }
  if (n < 0) {
    cout << "-1";
    return 0;
  }
  while (n--) {
    int machau = 0, cnt = 0;
    int p;
    bool flag = 0;
    for (int i = 0; i < 26; i++) {
      if (a[i] != 0) {
        flag = 1;
        cnt = (a[i] + ans[i] - 1) / ans[i];
        if (machau < cnt) {
          machau = cnt;
          p = i;
        }
      }
    }
    if (flag == 0) break;
    a[p]--;
    ans[p]++;
  }
  for (int i = 0; i < 26; i++) a[i] = 0;
  for (int i = 0; i < s.length(); i++) a[s[i] - 'a']++;
  int maxx = 0;
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    if (a[i] != 0) {
      cnt = (a[i] + ans[i] - 1) / ans[i];
      if (maxx < cnt) maxx = cnt;
    }
  }
  cout << maxx << endl;
  string anss = "";
  for (int i = 0; i < 26; i++) {
    while (ans[i]--) anss += ('a' + i);
  }
  n++;
  while (n--) {
    anss += anss[0];
  }
  cout << anss;
}
