#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int> freq(26, 0);
  for (int i = 0; i < (int)s.size(); ++i) freq[s[i] - 'a']++;
  int ans = -1;
  string s_ans = "";
  for (int lf = 1, rt = 2000; lf <= rt;) {
    int mid = (lf + rt) >> 1;
    int total = 0;
    string now = "";
    vector<int> need(26, 0);
    for (int i = 0; i < 26; ++i) {
      int t = freq[i] / mid;
      if (freq[i] % mid) t++;
      need[i] = t;
      total += need[i];
    }
    if (total <= n) {
      rt = mid - 1;
      ans = mid;
      for (int i = 0; i < 26; ++i)
        for (int j = 0; j < need[i]; ++j) now += char(i + 'a');
      for (; (int)now.size() < n;) now.push_back(now[0]);
      s_ans = now;
    } else
      lf = mid + 1;
  }
  cout << ans << "\n";
  if (ans != -1) cout << s_ans << "\n";
  return 0;
}
