#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e9;
long long n, k;
string s;
bool check(long long mid) {
  long long sum = 0, last = -1, l = -1;
  long long x;
  for (int i = 0; i < n; i++) {
    if (s[i] == ' ' || s[i] == '-') {
      if ((i - last) <= mid) {
        l = i;
      } else {
        if (l == last) return 0;
        sum++;
        last = l;
        i--;
      }
    }
  }
  long long i = n - 1;
  if ((i - last) <= mid) {
    sum++;
  } else {
    if (l == last) return 0;
    sum++;
    last = l;
    if ((i - last) <= mid)
      sum++;
    else
      return 0;
  }
  if (sum <= k)
    return 1;
  else
    return 0;
}
int main() {
  cin >> k;
  getline(cin, s);
  getline(cin, s);
  n = s.size();
  long long l = 1, r = 1e6 + 1;
  long long res = -1;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      r = mid;
      res = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << res;
  return 0;
}
