#include #include #include #include int op(int x, int y) { return std::max(x, y); } int e() { return 0; } int main() { std::string s; std::cin >> s; const int n = s.size(); std::vector z = atcoder::z_algorithm(s); atcoder::segtree seg(z); std::vector dp(n + 1, n); dp[1] = 1; for (int i = 1; i < n; ++i) { dp[i + 1] = std::min(dp[i + 1], dp[i] + 1); int c = dp[i] + 1; for (int j = i; j < n;) { int nj = seg.max_right(j, [&](int v) { return v < i; }); if (nj == n) break; c += (nj - j) + 1; dp[nj + i] = std::min(dp[nj + i], c); j = nj + i; } } std::cout << dp[n] << std::endl; }