#include <bits/stdc++.h>
using namespace std;
int n;
string str;
map<char, int> num;
void print(char x, int y) {
  for (int i = 0; i < y; i++) {
    cout << x;
  }
}
bool check(double x) {
  int s = 0;
  for (auto tmp : num) {
    s += ceil(tmp.second / x);
  }
  if (s <= n) {
    return true;
  }
  return false;
}
void solve() {
  for (int i = 0; i < str.size(); i++) {
    num[str[i]]++;
  }
  int r = 1010, l = 0;
  while (l + 1 < r) {
    int m = (r + l) / 2;
    if (check(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  if (r == 1010) {
    cout << -1;
  } else {
    cout << r << endl;
    int cnt = 0;
    for (auto tmp : num) {
      int x = ceil(tmp.second / (double)r);
      print(tmp.first, x);
      cnt += x;
    }
    if (cnt < n) {
      print('a', n - cnt);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> str;
  cin >> n;
  solve();
}
