#include <bits/stdc++.h>
using namespace std;
int Up(int a, int b) { return (a + b - 1) / b; }
class Type {
 public:
  char ch;
  int number;
  int k;
  int value;
  Type() {}
  Type(char _ch, int _number) : ch(_ch), number(_number), k(0) {}
  friend bool operator<(const Type& a, const Type& b) {
    return a.number < b.number;
  }
  void Change() {
    ++k;
    value = Up(number, k);
  }
};
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  int m[256] = {0};
  for (int i = 0; i < (int)s.size(); ++i) {
    ++m[s[i]];
  }
  vector<Type> ss;
  for (char ch = 'a'; ch <= 'z'; ++ch) {
    if (m[ch] != 0) {
      ss.push_back(Type(ch, m[ch]));
    }
  }
  sort(ss.rbegin(), ss.rend());
  for (int i = 0; i < (int)ss.size(); ++i) {
    ss[i].Change();
  }
  if ((int)ss.size() > n) {
    cout << "-1" << endl;
    return 0;
  }
  int cnt = (int)ss.size();
  int pos = 0;
  while (cnt < n) {
    int _maxN = 0;
    for (int i = 1; i < (int)ss.size(); ++i) {
      if (ss[i].value > ss[_maxN].value) {
        _maxN = i;
      }
    }
    ss[_maxN].Change();
    ++cnt;
  }
  int ans = 0;
  for (int i = 0; i < (int)ss.size(); ++i) {
    ans = max(ans, ss[i].value);
  }
  cout << ans << endl;
  for (int i = 0; i < (int)ss.size(); ++i) {
    for (int j = 0; j < ss[i].k; ++j) {
      cout << ss[i].ch;
    }
  }
  cout << endl;
  return 0;
}
