#include <bits/stdc++.h>
using namespace std;
string s;
int c[26];
bool check(int m, string t) {}
bool solve() {
  int l = 1, r = 10000;
  while (l <= r) {
  }
}
bool compare(pair<char, int> a, pair<char, int> b) {
  return a.second > b.second;
}
int main() {
  cin >> s;
  int n;
  cin >> n;
  unordered_set<char> st;
  map<char, int> mp;
  for (auto ch : s) st.insert(ch), c[ch - 'a']++, mp[ch]++;
  ;
  vector<pair<char, int>> vp;
  for (auto xx : mp) vp.push_back(make_pair(xx.first, xx.second));
  sort(vp.begin(), vp.end(), compare);
  int mx = vp.front().second;
  if (st.size() > n)
    return cout << -1 << endl, 0;
  else if (st.size() == n) {
    cout << mx << endl;
    for (auto x : st) cout << x;
    cout << endl;
  } else {
    map<char, int> mc1;
    string ans;
    for (auto x : st) ans.push_back(x), mc1[x]++;
    for (int i = 0; i < n - st.size(); i++) {
      double mxx = INT_MIN;
      char cc;
      for (auto x : mp) {
        double tmp = (double)x.second / mc1[x.first];
        if (tmp > mxx) {
          mxx = tmp;
          cc = x.first;
        }
      }
      ans.push_back(cc);
      mc1[cc]++;
    }
    int aa = INT_MIN;
    for (auto xx : mp)
      aa = max((int)ceil(xx.second / (double)mc1[xx.first]), aa);
    cout << aa << endl;
    cout << ans << endl;
  }
}
