#include <bits/stdc++.h>
using namespace std;
long long GI(long long &a) { return scanf("%I64d", &a); }
long long n, i, j, k, tmp, m;
long long arr[100100];
string s, s1;
int32_t main() {
  getline(cin, s1);
  getline(std::cin, s);
  k = 0;
  for (long long i = 0; i < s1.length(); i++) k = k * 10 + s1[i] - '0';
  n = s.length();
  long long cur = 0;
  vector<long long> l;
  long long mm = 0;
  for ((i) = 0; (i) < (long long)(n); ++i) {
    cur++;
    if (s[i] == '-' || s[i] == ' ') {
      l.push_back(cur);
      mm = (mm > cur ? mm : cur);
      cur = 0;
    }
  }
  if (cur > 0) {
    l.push_back(cur);
    mm = max(mm, cur);
  }
  long long le = mm, r = 1000000, mid;
  while (le < r) {
    mid = (le + r) / 2;
    long long cnt = 0;
    long long last = 1000000;
    for (long long i = 0; i < l.size(); i++) {
      if (last + l[i] > mid) {
        cnt++;
        last = l[i];
      } else
        last = last + l[i];
    }
    if (cnt <= k)
      r = mid;
    else
      le = mid + 1;
  }
  cout << le;
}
