#include #include #include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; namespace RMQ{ using S = int; S op(S l, S r){ return max(l, r); } S e(){ return -1; } using Segtree = atcoder::segtree; } int main(){ string S; cin >> S; auto Z = atcoder::z_algorithm(S); int n = S.size(); RMQ::Segtree segtree(atcoder::z_algorithm(S)); vector dp(n+1); rep(i,n+1) dp[i] = i; for(int x=1; x<=n; x++){ dp[x] = min(dp[x], dp[x-1] + 1); int p = x, t = dp[x] + 1; while(p < n){ int nx = segtree.max_right(p, [x](int v){ return v= n) break; t += nx - p + 1; p = nx + x; dp[p] = min(dp[p], t); } } cout << dp[n] << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;