#include <bits/stdc++.h>
using namespace std;
string s;
int n, cnt;
int c[30];
int need[30];
bool pos(int u) {
  int ret = 0;
  for (int i = 0; i < 26; ++i) {
    need[i] = (int)ceil((double)c[i] / u);
    if (need[i]) ret += need[i];
  }
  return (ret <= n);
}
int main() {
  cin >> s >> n;
  for (int i = 0; i < s.size(); ++i) {
    cnt += !c[s[i] - 'a'];
    ++c[s[i] - 'a'];
  }
  if (cnt > n) {
    cout << "-1\n";
    return 0;
  }
  int low = 1, hi = 1000;
  while (low != hi) {
    int mid = (low + hi) / 2;
    if (pos(mid))
      hi = mid;
    else
      low = mid + 1;
  }
  cout << low << endl;
  pos(low);
  int t = 0;
  for (int i = 0; i < n; ++i) {
    if (t == 26) {
      cout << 'a';
      continue;
    }
    if (need[t] == 0) {
      ++t;
      --i;
      continue;
    }
    cout << char(t + 'a');
    --need[t];
  }
  cout << endl;
  return 0;
}
