fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. string line;
  6. getline(cin, line);
  7. size_t ans, dot = line.find_first_of('.');
  8. if (dot != string::npos)
  9. ans = count(line.begin(), line.begin() + dot, 'b');
  10. else
  11. ans = count(line.begin(), line.end(), 'b');
  12. cout << ans << endl;
  13. return 0;
  14. }
Success #stdin #stdout 0s 3276KB
stdin
banana
stdout
1