#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE = 100 + 10;
int main() {
  string s;
  int n, num[26 + 10], type = 0;
  int num2[26 + 10];
  fill(num, num + 26 + 10, 0);
  fill(num2, num2 + 20 + 10, 0);
  cin >> s;
  cin >> n;
  for (int i = 0; i < (int)s.length(); i++) {
    if (!num[(int)s[i] - 96]) type++;
    num[int(s[i]) - 96]++;
  }
  if (n < type)
    cout << -1 << endl;
  else {
    for (int i = 1; i <= 26; i++)
      if (num[i]) num2[i] = 1, n--;
    int maxi, pos;
    while (n > 0) {
      maxi = -1, pos = 0;
      for (int i = 1; i <= 26; i++)
        if (num2[i] > 0 && (num[i] + num2[i] - 1) / num2[i] > maxi) {
          maxi = (num[i] + num2[i] - 1) / num2[i];
          pos = i;
        }
      n--;
      num2[pos]++;
    }
    maxi = -1, pos = 0;
    for (int i = 1; i <= 26; i++)
      if (num2[i] > 0 && (num[i] + num2[i] - 1) / num2[i] > maxi) {
        maxi = (num[i] + num2[i] - 1) / num2[i];
        pos = i;
      }
    cout << maxi << endl;
    for (int i = 1; i <= 26; i++)
      for (int j = 1; j <= num2[i]; j++) cout << char(i + 96);
  }
  return 0;
}
