#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int H[30];
int ans;
vector<pair<int, int> > V;
string fin;
bool poss(int cnt) {
  int sz = V.size();
  int k = 0;
  string tmp;
  for (int i = 0; i < sz; i++) {
    int lol = V[i].first / cnt;
    if (V[i].first % cnt != 0) lol++;
    for (int j = 0; j < lol; j++) tmp += (V[i].second + 'a');
    k += lol;
  }
  int lz = tmp.size();
  while (lz < n) {
    tmp += 'a';
    lz++;
  }
  if (k <= n) {
    ans = cnt;
    fin = tmp;
    return true;
  }
  return false;
}
int main() {
  cin >> s;
  cin >> n;
  int sz = s.size();
  for (int i = 0; i <= 26; i++) H[i] = 0;
  for (int i = 0; i < sz; i++) {
    H[s[i] - 'a']++;
  }
  int c = 0;
  for (int i = 0; i < 26; i++) {
    if (H[i] != 0) {
      c++;
      V.push_back(make_pair(H[i], i));
    }
  }
  if (c > n) {
    cout << "-1\n";
    return 0;
  }
  sort(V.begin(), V.end());
  int hi = V[V.size() - 1].first;
  int lo = 1;
  int mid;
  ans = hi + 1;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    if (poss(mid)) {
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  cout << ans << endl;
  cout << fin << endl;
  return 0;
}
