#include <bits/stdc++.h>
using namespace std;
int n;
int freq[26], filled[26];
vector<pair<int, int> > vfreq;
bool good(int x) {
  int sfilled = 0;
  for (int i = 0; i < 26; i++) {
    filled[i] = (freq[i] + x - 1) / x;
    sfilled += filled[i];
  }
  if (sfilled <= n) return true;
  return false;
}
int main() {
  string s;
  cin >> s;
  cin >> n;
  memset(freq, 0, sizeof freq);
  for (int i = 0; i < s.size(); i++) {
    freq[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) vfreq.push_back(make_pair(freq[i], i));
  sort(vfreq.rbegin(), vfreq.rend());
  memset(filled, 0, sizeof filled);
  int lo = 1, hi = 1111;
  while (lo != hi) {
    int mid = (lo + hi) / 2;
    if (!good(mid)) {
      lo = mid + 1;
    } else {
      hi = mid;
    }
  }
  if (lo == 1111) {
    cout << -1 << endl;
    return 0;
  } else {
    cout << lo << endl;
    good(lo);
    int pcnt = 0;
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < filled[i]; j++) {
        cout << (char)('a' + i);
        pcnt++;
      }
    }
    for (int i = pcnt; i < n; i++) cout << 'a';
    cout << endl;
  }
  return 0;
}
