#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1010, ALPH = 30;
string S;
int N;
map<char, int> freq;
priority_queue<pair<int, char> > pq;
int times[ALPH];
int main() {
  cin >> S >> N;
  for (int i = 0; i < S.size(); i++) freq[S[i]]++;
  if (freq.size() > N) {
    cout << -1 << endl;
    return 0;
  }
  string sheet;
  for (map<char, int>::iterator it = freq.begin(); it != freq.end(); it++) {
    sheet += it->first;
    pq.push(make_pair(it->second, it->first));
    times[it->first - 'a']++;
  }
  while (sheet.size() < N) {
    pair<int, char> top = pq.top();
    pq.pop();
    sheet += top.second;
    times[top.second - 'a']++;
    pq.push(make_pair((freq[top.second] + times[top.second - 'a'] - 1) /
                          times[top.second - 'a'],
                      top.second));
  }
  cout << pq.top().first << endl;
  cout << sheet << endl;
  return 0;
}
