#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e5 + 10;
string s;
int dp[1001][26], f[26];
vector<pair<int, int>> v;
int giveres(int pos, int indx) {
  if (indx == v.size()) {
    return 0;
  }
  if (pos == 0) return 1e9;
  int &ret = dp[pos][indx];
  if (ret != -1) return ret;
  ret = 1e9;
  for (int i = 1; i <= v[indx].second; i++) {
    if (i <= pos) {
      int xx = v[indx].second / i;
      if (v[indx].second % i != 0) xx++;
      ret = min(ret, max(giveres(pos - i, indx + 1), xx));
    }
  }
  return ret;
}
void print(int pos, int indx) {
  if (indx == v.size()) {
    for (int i = 0; i < pos; i++) cout << "a";
    return;
  }
  if (pos == 0) return;
  int &ret = dp[pos][indx];
  for (int i = 1; i <= v[indx].second; i++) {
    if (i <= pos) {
      int xx = v[indx].second / i;
      if (v[indx].second % i != 0) xx++;
      if (ret == max(giveres(pos - i, indx + 1), xx)) {
        for (int j = 0; j < i; j++) cout << (char)('a' + v[indx].first);
        print(pos - i, indx + 1);
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  int len;
  cin >> len;
  for (char cc : s) f[cc - 'a']++;
  for (int i = 0; i < 26; i++)
    if (f[i]) v.push_back({i, f[i]});
  if (len < v.size()) {
    puts("-1");
    return 0;
  }
  memset(dp, -1, sizeof(dp));
  cout << giveres(len, 0) << "\n";
  print(len, 0);
  return 0;
}
