#include <bits/stdc++.h>
using namespace std;
long long dbg = 0;
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p);
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p);
template <typename A>
istream& operator>>(istream& cin, vector<A>& v);
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
map<char, long long> used;
long long cmp(pair<long long, char> a, pair<long long, char> b) {
  if (used[a.second] == used[b.second]) return a.first > b.first;
  return used[a.second] < used[b.second];
}
void solve() {
  string s;
  cin >> s;
  long long n;
  cin >> n;
  map<char, long long> arr;
  for (auto i : s) arr[i]++;
  if (arr.size() > n)
    cout << -1 << '\n';
  else {
    string t;
    long long ans = 0;
    for (long long i = 1;; i++) {
      long long sum = 0;
      long long pos = 0;
      for (auto j : arr) {
        sum += (j.second + i - 1) / i;
      }
      if (sum <= n) {
        ans = i;
        break;
      }
    }
    for (auto j : arr) {
      for (long long i = 0; i < (j.second + ans - 1) / ans; i++) t += j.first;
    }
    while (t.size() < n) t += 'a';
    cout << ans << '\n';
    cout << t << '\n';
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
  if (dbg) {
    dbg = 0;
    return cout << "(" << p.first << ", " << p.second << ")";
  } else {
    return cout << p.first << ' ' << p.second;
  }
}
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v) {
  if (dbg) {
    dbg = 0;
    cout << "[";
    for (long long i = 0; i < v.size(); i++) {
      if (i) cout << ", ";
      cout << v[i];
    }
    return cout << "]";
  } else {
    for (long long i = 0; i < v.size() - 1; i++) cout << v[i] << ' ';
    return cout << v[v.size() - 1];
  }
}
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p) {
  cin >> p.first;
  return cin >> p.second;
}
template <typename A>
istream& operator>>(istream& cin, vector<A>& v) {
  for (long long i = 0; i < v.size() - 1; i++) cin >> v[i];
  return cin >> v[v.size() - 1];
}
