#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int k;
char s[MAXN];
vector<int> vlen;
bool check(int n) {
  int sum = 0, cnt = 0;
  for (int ii = 0; ii < vlen.size(); ii++) {
    if (vlen[ii] > n) return false;
    if (sum + vlen[ii] > n) {
      cnt++;
      sum = vlen[ii];
    } else if (sum + vlen[ii] == n) {
      cnt++;
      sum = 0;
    } else
      sum += vlen[ii];
  }
  if (sum) cnt++;
  return cnt <= k;
}
int main() {
  scanf("%d\n", &k);
  cin.getline(s, MAXN);
  int ptr = 0;
  while (s[ptr] != '\0') {
    int cnt = 0;
    while (s[ptr] != '\0' && s[ptr] != ' ' && s[ptr] != '-') {
      ptr++;
      cnt++;
    }
    if (s[ptr] != '\0') ptr++, cnt++;
    vlen.push_back(cnt);
  }
  int l = 0, r = 1e6 + 10, ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  cout << ans;
}
