#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
char str[N];
int num[N], current[N];
struct Item {
  char c;
  int val;
  Item(char _c, int _val) : c(_c), val(_val) {}
  bool operator<(const Item& v) const { return val < v.val; }
};
int main() {
  int n;
  int diff = 0;
  scanf("%s", str);
  scanf("%d", &n);
  for (int i = 0; str[i]; i++) {
    if (num[(int)str[i]] == 0) diff++;
    num[(int)str[i]]++;
  }
  if (diff > n) {
    puts("-1");
    return 0;
  }
  priority_queue<Item> q;
  for (int k = 'a'; k <= 'z'; k++) {
    if (num[k] > 0) {
      q.push(Item(k, num[k]));
      current[k] = 1;
    }
  }
  while (n > diff) {
    Item u = q.top();
    q.pop();
    int k = u.c;
    current[k]++;
    if (num[k] % current[k] == 0)
      q.push(Item(k, num[k] / current[k]));
    else
      q.push(Item(k, (int)(num[k] / current[k]) + 1));
    n--;
  }
  printf("%d\n", q.top().val);
  for (int k = 'a'; k <= 'z'; k++) {
    for (int l = 1; l <= current[k]; l++) putchar((char)k);
  }
  puts("");
  return 0;
}
