#include <bits/stdc++.h>
using namespace std;
namespace p335ABanana {
void solve(int test_num) {
  int cnt[26] = {0};
  string str;
  int n;
  cin >> str >> n;
  for (int i = 0; i < (int)str.size(); i++) cnt[str[i] - 'a']++;
  for (int res = 1; res <= 1000; res++) {
    int need = 0;
    for (int c = 0; c < 26; c++) need += (cnt[c] + res - 1) / res;
    if (need <= n) {
      cout << res << endl;
      for (int c = 0; c < 26; c++) {
        int am = (cnt[c] + res - 1) / res;
        for (int i = 0; i < am; i++) cout << char(c + 'a');
        n -= am;
      }
      while (n--) cout << 'z';
      cout << endl;
      return;
    }
  }
  cout << -1 << endl;
}
void solve() { solve(1); }
}  // namespace p335ABanana
int main() {
  p335ABanana::solve();
  return 0;
}
