#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  string str;
  while (cin >> str >> N) {
    int ch[109], ar[109];
    memset(ch, 0, sizeof(ch));
    memset(ar, 0, sizeof(ar));
    for (int i = 0, _n = str.size(); i < _n; i++) {
      ar[str[i] - 'a']++;
    }
    int rex = 0, rey = 0;
    for (int i = 0, _n = 26; i < _n; i++)
      if (ar[i]) rey++;
    if (rey > N) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 1, _n = 1001; i < _n; i++) {
      int r = 0;
      for (int j = 0, _n = 26; j < _n; j++) {
        r += ar[j] / i + (ar[j] % i > 0);
      }
      if (r <= N) {
        rex = i;
        break;
      }
    }
    int t = 0;
    cout << rex << endl;
    for (int i = 0, _n = 26; i < _n; i++) {
      if (ar[i]) {
        int r = ar[i] / rex + (ar[i] % rex > 0);
        for (int j = 0, _n = r; j < _n; j++) cout << (char)(i + 'a'), t++;
      }
    }
    while (t < N) cout << "a", t++;
  }
  return 0;
}
