#include <bits/stdc++.h>
using namespace std;
char s[100005];
int i, j, p[26], ans, A, k;
int main() {
  scanf("%s", s);
  for (i = 0; i < strlen(s); i++) p[s[i] - 'a']++;
  scanf("%d", &A);
  int t = 0;
  for (i = 1; i <= 1000; i++) {
    ans = 0;
    for (j = 0; j < 26; j++)
      if (p[j] != 0) ans += (p[j] - 1) / i + 1;
    if (ans <= A) {
      cout << i << endl;
      for (j = 0; j < 26; j++)
        if (p[j] != 0)
          for (k = 1; k <= (p[j] - 1) / i + 1; k++) {
            if (t == A) return 0;
            t++;
            cout << char(j + 'a');
          }
      while (t != A) {
        cout << 'a';
        t++;
      }
      return 0;
    }
  }
  cout << -1;
  return 0;
}
