#include <bits/stdc++.h>
using namespace std;
vector<string> a;
int k;
int check(int x) {
  int need = 1;
  int rem = x;
  for (int i = 0; i < a.size(); i++) {
    if (a[i].size() > x) return 0;
    if (rem >= a[i].size())
      rem -= a[i].size();
    else {
      rem = x - a[i].size();
      need++;
    }
  }
  return need <= k;
}
int main() {
  cin >> k;
  string s;
  while (cin >> s) {
    string m = "";
    for (int i = 0; i < s.size(); i++) {
      m += s[i];
      if (s[i] == '-') {
        a.push_back(m);
        m = "";
      }
    }
    m += ' ';
    a.push_back(m);
  }
  a.back().resize(a.back().size() - 1);
  int l = 1, hi = 1e6, mid, best = 0;
  while (l <= hi) {
    mid = (l + hi) / 2;
    if (check(mid)) {
      best = mid;
      hi = mid - 1;
    } else
      l = mid + 1;
  }
  cout << best;
  return 0;
}
