#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Edge {
  long long to, cap, rev;
  Edge(long long _to, long long _cap, long long _rev) {
    to = _to;
    cap = _cap;
    rev = _rev;
  }
};
void add_edge(vector<vector<Edge>>& G, long long from, long long to,
              long long cap, bool revFlag, long long revCap) {
  G[from].push_back(Edge(to, cap, (long long)G[to].size()));
  if (revFlag)
    G[to].push_back(Edge(from, revCap, (long long)G[from].size() - 1));
}
long long max_flow_dfs(vector<vector<Edge>>& G, long long v, long long t,
                       long long f, vector<bool>& used) {
  if (v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); ++i) {
    Edge& e = G[v][i];
    if (!used[e.to] && e.cap > 0) {
      long long d = max_flow_dfs(G, e.to, t, min(f, e.cap), used);
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
long long max_flow(vector<vector<Edge>>& G, long long s, long long t) {
  long long flow = 0;
  for (;;) {
    vector<bool> used(G.size());
    for (long long(i) = 0; (i) < (used.size()); (i)++) used[i] = false;
    long long f = max_flow_dfs(G, s, t, INF, used);
    if (f == 0) {
      return flow;
    }
    flow += f;
  }
}
void BellmanFord(vector<vector<Edge>>& G, long long s, vector<long long>& d,
                 vector<long long>& negative) {
  d.resize(G.size());
  negative.resize(G.size());
  for (long long(i) = 0; (i) < (d.size()); (i)++) d[i] = INF;
  for (long long(i) = 0; (i) < (d.size()); (i)++) negative[i] = false;
  d[s] = 0;
  for (long long(k) = 0; (k) < (G.size() - 1); (k)++) {
    for (long long(i) = 0; (i) < (G.size()); (i)++) {
      for (long long(j) = 0; (j) < (G[i].size()); (j)++) {
        if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
          d[G[i][j].to] = d[i] + G[i][j].cap;
        }
      }
    }
  }
  for (long long(k) = 0; (k) < (G.size() - 1); (k)++) {
    for (long long(i) = 0; (i) < (G.size()); (i)++) {
      for (long long(j) = 0; (j) < (G[i].size()); (j)++) {
        if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
          d[G[i][j].to] = d[i] + G[i][j].cap;
          negative[G[i][j].to] = true;
        }
        if (negative[i] == true) negative[G[i][j].to] = true;
      }
    }
  }
}
void Dijkstra(vector<vector<Edge>>& G, long long s, vector<long long>& d) {
  d.resize(G.size());
  for (long long(i) = 0; (i) < (d.size()); (i)++) d[i] = INF;
  d[s] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      q;
  q.push(make_pair(0, s));
  while (!q.empty()) {
    pair<long long, long long> a = q.top();
    q.pop();
    if (d[a.second] < a.first) continue;
    for (long long(i) = 0; (i) < (G[a.second].size()); (i)++) {
      Edge e = G[a.second][i];
      if (d[e.to] > d[a.second] + e.cap) {
        d[e.to] = d[a.second] + e.cap;
        q.push(make_pair(d[e.to], e.to));
      }
    }
  }
}
void WarshallFloyd(vector<vector<Edge>>& G, vector<vector<long long>>& d) {
  d.resize(G.size());
  for (long long(i) = 0; (i) < (d.size()); (i)++) d[i].resize(G.size());
  for (long long(i) = 0; (i) < (d.size()); (i)++) {
    for (long long(j) = 0; (j) < (d[i].size()); (j)++) {
      d[i][j] = INF;
    }
  }
  for (long long(i) = 0; (i) < (G.size()); (i)++) {
    for (long long(j) = 0; (j) < (G[i].size()); (j)++) {
      d[i][G[i][j].to] = G[i][j].cap;
    }
  }
  for (long long(i) = 0; (i) < (G.size()); (i)++) {
    for (long long(j) = 0; (j) < (G.size()); (j)++) {
      for (long long(k) = 0; (k) < (G.size()); (k)++) {
        chmin(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}
class UnionFind {
  vector<int> data;
  int num;

 public:
  UnionFind(int size) : data(size, -1), num(size) {}
  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
      num--;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
  int numSet() { return num; }
};
class Combination {
 public:
  vector<long long> fact;
  vector<long long> inv;
  long long mod;
  Combination(long long n, long long _mod) {
    mod = _mod;
    fact.resize(n + 1);
    fact[0] = 1;
    for (long long(i) = 0; (i) < (n); (i)++) {
      fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
    }
    inv.resize(n + 1);
    for (long long(i) = 0; (i) < (n + 1); (i)++) {
      inv[i] = mod_inv(fact[i]);
    }
  }
  long long mod_inv(long long x) {
    long long n = mod - 2;
    long long res = 1LL;
    while (n > 0) {
      if (n & 1) res = res * x % mod;
      x = x * x % mod;
      n >>= 1;
    }
    return res;
  }
  long long nCr(long long n, long long r) {
    return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
  }
  long long nPr(long long n, long long r) {
    return (fact[n] * inv[n - r]) % mod;
  }
  long long nHr(long long n, long long r) { return nCr(r + n - 1, r); }
};
void divisor(long long n, vector<long long>& ret) {
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end(), greater<long long>());
}
void factoring(long long i, map<long long, long long>& mp) {
  long long x = i;
  for (int j = 2; j <= i; j++) {
    if (x % j == 0) {
      if (mp.find(j) == mp.end()) {
        mp[j] = 0;
      }
      while (x % j == 0 && x > 1) {
        mp[j]++;
        x /= j;
      }
    }
    if (x == 1) break;
  }
}
long long gcd(long long m, long long n) {
  if (n == 0) return m;
  return gcd(n, m % n);
}
long long lcm(long long m, long long n) { return m / gcd(m, n) * n; }
long long pow2(long long x, long long n, long long mod) {
  long long ans = 1ll;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return ans;
}
vector<long long> lis_fast(const vector<long long>& a) {
  const long long n = a.size();
  vector<long long> A(n, INT_MAX);
  vector<long long> id(n);
  for (int i = 0; i < n; ++i) {
    id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
    A[id[i]] = a[i];
  }
  long long m = *max_element(id.begin(), id.end());
  vector<long long> b(m + 1);
  for (int i = n - 1; i >= 0; --i)
    if (id[i] == m) b[m--] = a[i];
  return b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string pre = s.substr(0, 1);
  long long i = 1;
  long long con = 0;
  long long num = 1;
  long long j = s.size();
  while (i < s.size()) {
    if (pre == s.substr(i, 1)) {
      if (i + 1 == s.size()) {
        con += 2;
        num += ((long long)(con / 3)) * 2;
        if (con % 3 != 0) num++;
        num--;
        if (con % 3 == 2) {
          if (j == i - con) {
            num++;
          } else {
            j = i;
          }
        }
        con = 0;
        i++;
      } else if (pre == s.substr(i + 1, 1)) {
        con++;
        i++;
      } else {
        if (con > 0) {
          con += 2;
          num += ((long long)(con / 3)) * 2;
          if (con % 3 != 0) num++;
          num--;
          if (con % 3 == 2) {
            if (j == i - con) {
              num++;
            } else {
              j = i;
            }
          }
          con = 0;
          i++;
        } else {
          if (j == i - 2) {
            pre = s.substr(i, 1);
            num++;
            i++;
          } else {
            pre = s.substr(i, 2);
            num++;
            i += 2;
          }
        }
      }
    } else {
      pre = s.substr(i, 1);
      i++;
      num++;
    }
  }
  cout << num << endl;
  return 0;
}
