#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
const int inf = 1 << 30;
char s[1010];
int cnt[26], n;
int main() {
  cin >> s >> n;
  for (int i = 0; s[i]; i++) cnt[s[i] - 'a']++;
  for (int t = 1; t <= 1000; t++) {
    int sum = 0;
    for (int i = 0; i < 26; i++) sum += (cnt[i] + t - 1) / t;
    if (sum <= n) {
      cout << t << endl;
      for (int i = 0; i < 26; i++)
        for (int j = 0; j < (cnt[i] + t - 1) / t; j++) {
          putchar('a' + i);
          n--;
        }
      for (int i = 0; i < n; i++) putchar('a');
      return 0;
    }
  }
  cout << -1;
  return 0;
}
