#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
string s;
int n;
string ans;
bool ok(int a) {
  ans.clear();
  string k;
  for (auto p : m) {
    k += string((p.second + a - 1) / a, p.first);
  }
  if (k.size() > n) return false;
  int b = k.size();
  for (int i = 0; i < n - b; i++) k += s[0];
  ans = k;
  return true;
}
int main() {
  cin >> s;
  cin >> n;
  for (auto p : s) {
    m[p]++;
  }
  int l = 1, r = 1000;
  int cnt = 400;
  while (cnt--) {
    int mid = (l + r) / 2;
    if (ok(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (!ok(l))
    cout << -1;
  else {
    cout << l << "\n";
    cout << ans;
  }
}
