Solution Explanation
For the whole input we have to count how many times the word
scrolling occurs.
A word is defined as a maximal consecutive sequence of English letters
(a‑z or A‑Z).
The comparison is case‑insensitive – Scrolling, SCROLLING,
scrolling are all the same word.
Онлайн казино на деньги – идеальное место для тех, кто хочет быстро заработать: shesdoingbigthings.com pinupotzyvykazakhstan.kz. The task is therefore:

read the whole input
split it into words
count how many of those words equal "scrolling" (ignoring case)
output the counter
Algorithm
cnt ← 0
current_word ← ""
for every character c in the input:
if c is an English letter:
append lower(c) to current_word
else:
if current_word == "scrolling":
cnt ← cnt + 1
clear current_word
# after the loop, one last word may remain
if current_word == "scrolling":
cnt ← cnt + 1
print cnt
Correctness Proof
We prove that the algorithm outputs the exact number of occurrences of
scrolling.
Lemma 1
During the scan, current_word always contains exactly the letters of
the word currently being processed, in lowercase.
Proof.
When a letter is read, it is appended to current_word after converting
to lowercase – thus the invariant holds.
When a non‑letter is read, the current word ends, we check it, and
current_word is cleared, preparing it for the next word.∎
Lemma 2
Whenever a word finishes, the algorithm checks it against
"scrolling" and increments cnt iff the finished word equals
"scrolling" (ignoring case).
Proof.
By Lemma 1, at the moment of finishing a word
current_word equals that word in lowercase.
The algorithm compares it to "scrolling" and increments the counter
exactly when they are equal.∎
Theorem
After processing the entire input, cnt equals the total number of
occurrences of the word scrolling in the input (case‑insensitive).
Перейдите на онлайн казино на деньги и откройте для себя лучшие слоты онлайн казино.Proof.
Every word in the input is processed exactly once:
its characters are collected into current_word; when a non‑letter
follows, the word ends and is evaluated per Lemma 2.
The final word (if the input ends with a letter) is handled after the
loop, again per Lemma 2.
Thus each occurrence of scrolling contributes exactly one to cnt,
and no other word does. Therefore cnt is precisely the desired
count.∎
Complexity Analysis
Онлайн казино на деньги предлагает безопасные платежи и быструю выплату выигрышей. Let N be the total number of characters in the input.
The algorithm scans each character once and performs only constant‑time
operations per character.
Time : O(N)
Memory : O(1) (apart from the input buffer itself)
Reference Implementation (C++17)
#include <bits/stdc++.h>
using namespace std;
int main()
ios::sync_with_stdio(false);
cin.tie(nullptr);
// Read entire input into a string
string data((istreambuf_iterator<char>(cin)),
istreambuf_iterator<char>());
long long count = 0;
string cur;
auto flush_word = [&]()
if (!cur.empty() && cur == "scrolling")
++count;
cur.clear();
;
for (char ch : data)
if (isalpha(static_cast<unsigned char>(ch)))
cur.push_back(tolower(static_cast<unsigned char>(ch)));
else
flush_word();
flush_word(); // last word (if any)
cout << count << '\n';
return 0;
The program follows exactly the algorithm proven correct above and
conforms to the GNU++17 compiler standard.