#include <bits/stdc++.h>
using namespace std;
long long ch[30];
bool check(long long k, long long n) {
  long long res = 0;
  for (long long i = 0; i < 30; i++)
    if (ch[i]) res += ch[i] / k + (ch[i] % k != 0);
  if (res <= n) return true;
  return false;
}
int main() {
  string s;
  cin >> s;
  long long n;
  cin >> n;
  long long L = s.size();
  for (long long i = 0; i < L; i++) {
    ch[s[i] - 'a']++;
  }
  long long cnt = 0;
  for (long long i = 0; i < 30; i++) cnt += (ch[i] > 0);
  if (cnt > n) return cout << -1 << '\n', 0;
  long long ans, lo = 1, hi = 1e16;
  while (lo <= hi) {
    long long mid = (lo + hi) >> 1;
    if (check(mid, n)) {
      ans = mid;
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  cout << ans << '\n';
  long long y = 0;
  for (long long i = 0; i < 30; i++) {
    if (ch[i]) {
      long long x = ch[i] / ans + (ch[i] % ans != 0);
      y += x;
      while (x) {
        cout << (char)(i + 'a');
        x--;
      }
    }
  }
  while (y < n) cout << 'x', y++;
  return 0;
}
