#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double Pi = acos(-1);
using namespace std;
int debug = 01;
int main() {
  int k;
  string s;
  cin >> k;
  int c = 0;
  getchar();
  getline(cin, s);
  vector<int> v;
  for (auto x : s) {
    c++;
    if (x == '-' || x == ' ') v.push_back(c), c = 0;
  }
  v.push_back(c);
  int l = 0, r = 1000000;
  while (l < r) {
    int m = (l + r) / 2, y = 0;
    c = 0;
    for (auto x : v) {
      if (x > m) {
        c = k + k;
        break;
      }
      if (y + x > m) {
        c++;
        y = x;
      } else
        y += x;
      if (c > k) break;
    }
    if (y) c++;
    if (c > k)
      l = m + 1;
    else
      r = m;
  }
  cout << r;
}
