#include <bits/stdc++.h>
using namespace std;
long long n, l, r, mid, hasil, ans, sz;
map<char, long long> m;
map<char, bool> b;
vector<char> v;
string ss, s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> n;
  for (int i = 0; i < s.length(); i++) {
    if (b[s[i]] == false) {
      b[s[i]] = true;
      v.push_back(s[i]);
    }
    m[s[i]]++;
  }
  if (v.size() > n) {
    cout << -1 << '\n';
    return 0;
  }
  l = 1;
  r = s.length();
  while (l <= r) {
    string t;
    mid = (l + r) / 2;
    for (int i = 0; i < v.size(); i++) {
      hasil = (m[v[i]] + mid - 1) / mid;
      for (int j = 0; j < hasil; j++) {
        t += v[i];
      }
    }
    if (t.length() <= n) {
      sz = n - t.length();
      for (int i = 0; i < sz; i++) {
        t += v[0];
      }
      ss = t;
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  cout << ans << '\n' << ss << '\n';
  return 0;
}
