#include <bits/stdc++.h>
using namespace std;
set<char> st;
int a[26] = {0};
int main() {
  int n;
  string s;
  cin >> s >> n;
  for (auto c : s) {
    st.insert(c);
    a[c - 97]++;
  }
  if ((int)st.size() > n) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= 1000; ++i) {
    int co = 0;
    for (int j = 0; j <= 25; ++j) {
      co += ceil((double)a[j] / i);
    }
    if (co <= n) {
      printf("%d\n", i);
      for (int j = 0; j <= 25; ++j) {
        for (int k = 1; k <= ceil((double)a[j] / i); ++k) {
          printf("%c", ('a' + j));
        }
      }
      while (co < n) {
        printf("a");
        co++;
      }
      printf("\n");
      return 0;
    }
  }
}
