#include #include using namespace std; int main(){ // 入出力の高速化 ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; int ans = 0; stack s; s.push(-1); s.push(-1); for(int i=0; i> c; s.push(c); int top1 = s.top(); s.pop(); int top2 = s.top(); s.pop(); int top3 = s.top(); s.pop(); if(top1 == top2 && top2 == top3){ ans += 3; } else{ s.push(top3); s.push(top2); s.push(top1); } } cout << ans << "\n"; return 0; }