#include <bits/stdc++.h>
using namespace std;
const int MAX = 30;
int num[MAX], x[MAX];
char s[1000 + 10];
int main() {
  int n;
  while (cin >> s >> n) {
    int m = n;
    string a;
    memset(num, 0, sizeof num);
    int len = strlen(s), sum = 0;
    for (int i = 0; i < len; ++i) {
      if (!num[s[i] - 'a']) ++sum;
      ++num[s[i] - 'a'];
    }
    if (sum > n)
      cout << "-1";
    else {
      for (int i = 0; i < 26; ++i) {
        if (num[i]) {
          a += (i + 'a');
          --m;
        }
        x[i] = 1;
      }
      while (m) {
        int j = 0;
        for (int i = 0; i < 26; ++i) {
          if ((num[i] - 1) / x[i] + 1 > (num[j] - 1) / x[j] + 1) j = i;
        }
        a += (j + 'a');
        ++x[j];
        --m;
      }
      int j = 0;
      for (int i = 0; i < 26; ++i) {
        if ((num[i] - 1) / x[i] + 1 > (num[j] - 1) / x[j] + 1) j = i;
      }
      cout << (num[j] - 1) / x[j] + 1 << endl;
      cout << a;
    }
    cout << endl;
  }
  return 0;
}
