#include <bits/stdc++.h>
using namespace std;
vector<long long int> g[100005];
long long int vis[100005];
long long int prime[5000003] = {0};
long long int ncr[2005][2005];
long long int fact[1000005];
long long int inv[1000005];
vector<long long int> ans;
vector<long long int> divisor(long long int n) {
  vector<long long int> v;
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (n / i != i) v.push_back(n / i);
    }
  }
  return v;
}
vector<long long int> msieve() {
  prime[0] = 1;
  prime[1] = 1;
  vector<long long int> v;
  for (long long int i = 2; i <= 10002; i++) {
    if (prime[i] == 0) {
      prime[i] = i;
      for (long long int j = 2 * i; j <= 10002; j += i) prime[j] = i;
    }
  }
  for (long long int i = 2; i < 5000002; i++)
    if (prime[i] == i) v.push_back(i);
  return v;
}
long long int no_of_div(long long int n) {
  long long int c = 1, ans = 1;
  while (n > 1) {
    if (prime[n] == prime[n / prime[n]])
      c++;
    else {
      ans *= (c + 1);
      c = 1;
    }
    n = n / prime[n];
  }
  return ans;
}
vector<long long int> no_of_fact(long long int n) {
  vector<long long int> v;
  long long int c = 0, ans = 1;
  while (n > 1) {
    v.push_back(prime[n]);
    c++;
    n = n / prime[n];
  }
  return v;
}
long long binpow(long long int a, long long int b, long long int m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = ((a % m) * (a % m)) % m;
    b >>= 1;
  }
  return res;
}
void cal() {
  ncr[0][0] = 1;
  for (long long int i = 1; i <= 2004; i++) {
    ncr[i][0] = 1, ncr[i][i] = 1;
    for (long long int j = 1; j < i; j++) {
      ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]);
    }
  }
}
long long int nck(long long int x, long long int y) { return ncr[x][y]; }
void cal1() {
  fact[0] = 1;
  for (long long int i = 1; i < 1000005; i++) {
    fact[i] = (fact[i - 1] * i) % 998244353;
  }
  for (long long int i = 0; i < 1000005; i++) {
    inv[i] = binpow(fact[i], 998244353 - 2, 998244353);
  }
}
long long int ncr1(long long int x, long long int y) {
  return (((fact[x] * inv[y]) % 998244353) * inv[x - y]) % 998244353;
}
long long int gcd(long long int a, long long int b, long long int& x,
                  long long int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long int x1, y1;
  long long int d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long int fun(long long int x) {
  long long int y = 1;
  while (x) {
    if (x % 10 != 0) y *= (x % 10);
    x = x / 10;
  }
  if (y < 10)
    return y;
  else
    return fun(y);
}
void solve165b() {
  long long int n, k;
  cin >> n >> k;
  long long int l = 0, h = n, an = n;
  while (l <= h) {
    long long int mid = (l + h + 1) / 2;
    long long int x = k, y = mid;
    while (mid / x) {
      y += (mid / x);
      x = x * k;
    }
    if (y >= n) {
      an = mid;
      h = mid - 1;
    } else
      l = mid + 1;
  }
  cout << an;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    string s;
    cin >> s;
    long long int a[26] = {0};
    for (long long int i = 0; i < s.size(); i++) {
      a[s[i] - 'a']++;
    }
    long long int n;
    cin >> n;
    long long int l = 1, h = s.size(), an = s.size() + 5;
    while (l <= h) {
      long long int mid = (l + h + 1) / 2;
      long long int c = 0;
      for (long long int i = 0; i < 26; i++) c += ((a[i] + mid - 1) / mid);
      if (c <= n) {
        an = mid;
        h = mid - 1;
      } else
        l = mid + 1;
    }
    if (an > s.size())
      cout << -1;
    else {
      cout << an << endl;
      long long int c = 0;
      for (long long int i = 0; i < 26; i++) {
        long long int x = (a[i] + an - 1) / an;
        c += x;
        for (long long int j = 0; j < x; j++) {
          char x = 'a' + i;
          cout << x;
        }
      }
      for (long long int i = c; i < n; i++) cout << "z";
    }
  }
  return 0;
}
