Problem:
Score : 100 points

Problem Statement

We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.

Find the maximum number of consecutive rainy days in this period.

Constraints

|S| = 3

Each character of S is S or R.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of consecutive rainy days in the period.

Sample Input 1

RRS

Sample Output 1

2

We had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.

Sample Input 2

SSS

Sample Output 2

0

It was sunny throughout the period. We had no rainy days, so we should print 0.

Sample Input 3

RSR

Sample Output 3

1

We had rain on the 1-st and 3-rd days - two "streaks" of one rainy day, so we should print 1.

Solution in JavaScript (Node.js 12.16.1) (judge verdict: Accepted)

'use strict';Object.defineProperty(exports,'__esModule',{value:true});var fs=require('fs');var _length = function (xs) {
  return xs.length;
};
var _indexImpl = function (just) {
  return function (nothing) {
    return function (xs) {
      return function (i) {
        return i < 0 || i >= xs.length ? nothing : just(xs[i]);
      };
    };
  };
};
var _concat = function (xss) {
  if (xss.length <= 10000) {
    return Array.prototype.concat.apply([], xss);
  }
  var result = [];
  for (var i = 0, l = xss.length; i < l; i++) {
    var xs = xss[i];
    for (var j = 0, m = xs.length; j < m; j++) {
      result.push(xs[j]);
    }
  }
  return result;
};var _arrayMap = function (f) {
  return function (arr) {
    var l = arr.length;
    var result = new Array(l);
    for (var i = 0; i < l; i++) {
      result[i] = f(arr[i]);
    }
    return result;
  };
};var Semigroupoid = function (compose) {
    this.compose = compose;
};
var semigroupoidFn = new Semigroupoid(function (f) {
    return function (g) {
        return function (x) {
            return f(g(x));
        };
    };
});
var compose = function (dict) {
    return dict.compose;
};var flip = function (f) {
    return function (b) {
        return function (a) {
            return f(a)(b);
        };
    };
};
var $$const = function (a) {
    return function (v) {
        return a;
    };
};var _unit = {};var _showIntImpl = function (n) {
  return n.toString();
};var Show = function (show) {
    this.show = show;
};
var showInt = new Show(_showIntImpl);
var show = function (dict) {
    return dict.show;
};var Functor = function (map) {
    this.map = map;
};
var map = function (dict) {
    return dict.map;
};
var mapFlipped = function (dictFunctor) {
    return function (fa) {
        return function (f) {
            return map(dictFunctor)(f)(fa);
        };
    };
};
var $$void = function (dictFunctor) {
    return map(dictFunctor)($$const(_unit));
};
var functorFn = new Functor(compose(semigroupoidFn));
var functorArray = new Functor(_arrayMap);var _concatArray = function (xs) {
  return function (ys) {
    if (xs.length === 0) return ys;
    if (ys.length === 0) return xs;
    return xs.concat(ys);
  };
};var Semigroup = function (append) {
    this.append = append;
};
var semigroupArray = new Semigroup(_concatArray);
var append = function (dict) {
    return dict.append;
};var Alt = function (Functor0, alt) {
    this.Functor0 = Functor0;
    this.alt = alt;
};
var altArray = new Alt(function () {
    return functorArray;
}, append(semigroupArray));var _arrayApply = function (fs) {
  return function (xs) {
    var l = fs.length;
    var k = xs.length;
    var result = new Array(l * k);
    var n = 0;
    for (var i = 0; i < l; i++) {
      var f = fs[i];
      for (var j = 0; j < k; j++) {
        result[n++] = f(xs[j]);
      }
    }
    return result;
  };
};var Category = function (Semigroupoid0, identity) {
    this.Semigroupoid0 = Semigroupoid0;
    this.identity = identity;
};
var identity = function (dict) {
    return dict.identity;
};
var categoryFn = new Category(function () {
    return semigroupoidFn;
}, function (x) {
    return x;
});var Apply = function (Functor0, apply) {
    this.Functor0 = Functor0;
    this.apply = apply;
};
var applyArray = new Apply(function () {
    return functorArray;
}, _arrayApply);
var apply = function (dict) {
    return dict.apply;
};var Applicative = function (Apply0, pure) {
    this.Apply0 = Apply0;
    this.pure = pure;
};
var pure = function (dict) {
    return dict.pure;
};
var liftA1 = function (dictApplicative) {
    return function (f) {
        return function (a) {
            return apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a);
        };
    };
};var _arrayBind = function (arr) {
  return function (f) {
    var result = [];
    for (var i = 0, l = arr.length; i < l; i++) {
      Array.prototype.push.apply(result, f(arr[i]));
    }
    return result;
  };
};var Bind = function (Apply0, bind) {
    this.Apply0 = Apply0;
    this.bind = bind;
};
var bindArray = new Bind(function () {
    return applyArray;
}, _arrayBind);
var bind = function (dict) {
    return dict.bind;
};var Monad = function (Applicative0, Bind1) {
    this.Applicative0 = Applicative0;
    this.Bind1 = Bind1;
};
var ap = function (dictMonad) {
    return function (f) {
        return function (a) {
            return bind(dictMonad.Bind1())(f)(function (f$prime) {
                return bind(dictMonad.Bind1())(a)(function (a$prime) {
                    return pure(dictMonad.Applicative0())(f$prime(a$prime));
                });
            });
        };
    };
};var Bifunctor = function (bimap) {
    this.bimap = bimap;
};
var bimap = function (dict) {
    return dict.bimap;
};var _foldrArray = function (f) {
  return function (init) {
    return function (xs) {
      var acc = init;
      var len = xs.length;
      for (var i = len - 1; i >= 0; i--) {
        acc = f(xs[i])(acc);
      }
      return acc;
    };
  };
};
var _foldlArray = function (f) {
  return function (init) {
    return function (xs) {
      var acc = init;
      var len = xs.length;
      for (var i = 0; i < len; i++) {
        acc = f(acc)(xs[i]);
      }
      return acc;
    };
  };
};var Plus = function (Alt0, empty) {
    this.Alt0 = Alt0;
    this.empty = empty;
};var refEq = function (r1) {
  return function (r2) {
    return r1 === r2;
  };
};var Eq = function (eq) {
    this.eq = eq;
};
var eqChar = new Eq(refEq);
var eq = function (dict) {
    return dict.eq;
};var _boolConj = function (b1) {
  return function (b2) {
    return b1 && b2;
  };
};
var _boolDisj = function (b1) {
  return function (b2) {
    return b1 || b2;
  };
};
var _boolNot = function (b) {
  return !b;
};var HeytingAlgebra = function (conj, disj, ff, implies, not, tt) {
    this.conj = conj;
    this.disj = disj;
    this.ff = ff;
    this.implies = implies;
    this.not = not;
    this.tt = tt;
};
var not = function (dict) {
    return dict.not;
};
var disj = function (dict) {
    return dict.disj;
};
var heytingAlgebraBoolean = new HeytingAlgebra(_boolConj, _boolDisj, false, function (a) {
    return function (b) {
        return disj(heytingAlgebraBoolean)(not(heytingAlgebraBoolean)(a))(b);
    };
}, _boolNot, true);var Monoid = function (Semigroup0, mempty) {
    this.Semigroup0 = Semigroup0;
    this.mempty = mempty;
};
var mempty = function (dict) {
    return dict.mempty;
};var Nothing = function () {
    function Nothing() {}    Nothing.value = new Nothing();
    return Nothing;
}();
var Just = function () {
    function Just(value0) {
        this.value0 = value0;
    }    Just.create = function (value0) {
        return new Just(value0);
    };
    return Just;
}();
var maybe = function (v) {
    return function (v1) {
        return function (v2) {
            if (v2 instanceof Nothing) {
                return v;
            }            if (v2 instanceof Just) {
                return v1(v2.value0);
            }            throw new Error("Failed pattern match at Data.Maybe (line 217, column 1 - line 217, column 51): " + [v.constructor.name, v1.constructor.name, v2.constructor.name]);
        };
    };
};
var isNothing = maybe(true)($$const(false));
var functorMaybe = new Functor(function (v) {
    return function (v1) {
        if (v1 instanceof Just) {
            return new Just(v(v1.value0));
        }        return Nothing.value;
    };
});
var fromJust = function (dictPartial) {
    return function (v) {
        if (v instanceof Just) {
            return v.value0;
        }        throw new Error("Failed pattern match at Data.Maybe (line 268, column 1 - line 268, column 46): " + [v.constructor.name]);
    };
};var Foldable = function (foldMap, foldl, foldr) {
    this.foldMap = foldMap;
    this.foldl = foldl;
    this.foldr = foldr;
};
var foldr = function (dict) {
    return dict.foldr;
};
var foldl = function (dict) {
    return dict.foldl;
};
var foldMapDefaultR = function (dictFoldable) {
    return function (dictMonoid) {
        return function (f) {
            return foldr(dictFoldable)(function (x) {
                return function (acc) {
                    return append(dictMonoid.Semigroup0())(f(x))(acc);
                };
            })(mempty(dictMonoid));
        };
    };
};
var foldableArray = new Foldable(function (dictMonoid) {
    return foldMapDefaultR(foldableArray)(dictMonoid);
}, _foldlArray, _foldrArray);
var find = function (dictFoldable) {
    return function (p) {
        var go = function (v) {
            return function (v1) {
                if (v instanceof Nothing && p(v1)) {
                    return new Just(v1);
                }                return v;
            };
        };
        return foldl(dictFoldable)(go)(Nothing.value);
    };
};var semigroupFirst = new Semigroup(function (v) {
    return function (v1) {
        if (v instanceof Just) {
            return v;
        }        return v1;
    };
});
var monoidFirst = new Monoid(function () {
    return semigroupFirst;
}, Nothing.value);
var functorFirst = functorMaybe;
var altFirst = new Alt(function () {
    return functorFirst;
}, append(semigroupFirst));
var plusFirst = new Plus(function () {
    return altFirst;
}, mempty(monoidFirst));var semigroupLast = new Semigroup(function (v) {
    return function (v1) {
        if (v1 instanceof Just) {
            return v1;
        }        if (v1 instanceof Nothing) {
            return v;
        }        throw new Error("Failed pattern match at Data.Maybe.Last (line 52, column 1 - line 54, column 36): " + [v.constructor.name, v1.constructor.name]);
    };
});
var monoidLast = new Monoid(function () {
    return semigroupLast;
}, Nothing.value);
var functorLast = functorMaybe;
var altLast = new Alt(function () {
    return functorLast;
}, append(semigroupLast));
var plusLast = new Plus(function () {
    return altLast;
}, mempty(monoidLast));var _pureE = function (a) {
  return function () {
    return a;
  };
};
var _bindE = function (a) {
  return function (f) {
    return function () {
      return f(a())();
    };
  };
};var monadEffect = new Monad(function () {
    return applicativeEffect;
}, function () {
    return bindEffect;
});
var bindEffect = new Bind(function () {
    return applyEffect;
}, _bindE);
var applyEffect = new Apply(function () {
    return functorEffect;
}, ap(monadEffect));
var applicativeEffect = new Applicative(function () {
    return applyEffect;
}, _pureE);
var functorEffect = new Functor(liftA1(applicativeEffect));var _map_ = function (f) {
  return function (a) {
    return function () {
      return f(a());
    };
  };
};
var _new = function (val) {
  return function () {
    return { value: val };
  };
};
var _read = function (ref) {
  return function () {
    return ref.value;
  };
};
var _modify$prime = function (f) {
  return function (ref) {
    return function () {
      var t = f(ref.value);
      ref.value = t.state;
      return t.value;
    };
  };
};
var _write = function (a) {
  return function (ref) {
    return function () {
      return ref.value = a;
    };
  };
};var modify = function (f) {
    return _modify$prime(function (s) {
        var s$prime = f(s);
        return {
            state: s$prime,
            value: s$prime
        };
    });
};
var functorST = new Functor(_map_);var _empty = function () {
  return [];
};
var _pushAll = function (as) {
  return function (xs) {
    return function () {
      return xs.push.apply(xs, as);
    };
  };
};
var _unsafeFreeze = function (xs) {
  return function () {
    return xs;
  };
};var push = function (a) {
    return _pushAll([a]);
};var Iterator = function () {
    function Iterator(value0, value1) {
        this.value0 = value0;
        this.value1 = value1;
    }    Iterator.create = function (value0) {
        return function (value1) {
            return new Iterator(value0, value1);
        };
    };
    return Iterator;
}();
var peek = function (v) {
    return function __do() {
        var i = _read(v.value1)();
        return v.value0(i);
    };
};
var next = function (v) {
    return function __do() {
        var i = _read(v.value1)();
        modify(function (v1) {
            return v1 + 1 | 0;
        })(v.value1)();
        return v.value0(i);
    };
};
var pushWhile = function (p) {
    return function (iter) {
        return function (array) {
            return function __do() {
                var $$break = _new(false)();
                while (map(functorST)(not(heytingAlgebraBoolean))(_read($$break))()) {
                    (function __do() {
                        var mx = peek(iter)();
                        if (mx instanceof Just && p(mx.value0)) {
                            push(mx.value0)(array)();
                            return $$void(functorST)(next(iter))();
                        }                        return $$void(functorST)(_write(true)($$break))();
                    })();
                }                return {};
            };
        };
    };
};
var iterator = function (f) {
    return map(functorST)(Iterator.create(f))(_new(0));
};
var iterate = function (iter) {
    return function (f) {
        return function __do() {
            var $$break = _new(false)();
            while (map(functorST)(not(heytingAlgebraBoolean))(_read($$break))()) {
                (function __do() {
                    var mx = next(iter)();
                    if (mx instanceof Just) {
                        return f(mx.value0)();
                    }                    if (mx instanceof Nothing) {
                        return $$void(functorST)(_write(true)($$break))();
                    }                    throw new Error("Failed pattern match at Data.Array.ST.Iterator (line 42, column 5 - line 44, column 47): " + [mx.constructor.name]);
                })();
            }            return {};
        };
    };
};
var exhausted = function () {
    var $13 = map(functorST)(isNothing);
    return function ($14) {
        return $13(peek($14));
    };
}();var Tuple = function () {
    function Tuple(value0, value1) {
        this.value0 = value0;
        this.value1 = value1;
    }    Tuple.create = function (value0) {
        return function (value1) {
            return new Tuple(value0, value1);
        };
    };
    return Tuple;
}();
var bifunctorTuple = new Bifunctor(function (f) {
    return function (g) {
        return function (v) {
            return new Tuple(f(v.value0), g(v.value1));
        };
    };
});var singleton = function (a) {
    return [a];
};
var index = _indexImpl(Just.create)(Nothing.value);
var unzip = function (xs) {
    return function __do() {
        var fsts = _empty();
        var snds = _empty();
        var iter = iterator(function (v) {
            return index(xs)(v);
        })();
        iterate(iter)(function (v) {
            return function __do() {
                $$void(functorST)(push(v.value0)(fsts))();
                return $$void(functorST)(push(v.value1)(snds))();
            };
        })();
        var fsts$prime = _unsafeFreeze(fsts)();
        var snds$prime = _unsafeFreeze(snds)();
        return new Tuple(fsts$prime, snds$prime);
    }();
};
var head = function (xs) {
    return index(xs)(0);
};
var groupBy = function (op) {
    return function (xs) {
        return function __do() {
            var result = _empty();
            var iter = iterator(function (v) {
                return index(xs)(v);
            })();
            iterate(iter)(function (x) {
                return $$void(functorST)(function __do() {
                    var sub = _empty();
                    push(x)(sub)();
                    pushWhile(op(x))(iter)(sub)();
                    var grp = _unsafeFreeze(sub)();
                    return push(grp)(result)();
                });
            })();
            return _unsafeFreeze(result)();
        }();
    };
};
var group = function (dictEq) {
    return function (xs) {
        return groupBy(eq(dictEq))(xs);
    };
};
var concatMap = flip(bind(bindArray));
var mapMaybe = function (f) {
    return concatMap(function () {
        var $94 = maybe([])(singleton);
        return function ($95) {
            return $94(f($95));
        };
    }());
};
var catMaybes = mapMaybe(identity(categoryFn));var functorNonEmptyArray = functorArray;
var bindNonEmptyArray = bindArray;var _unsafeCoerce = function (x) {
  return x;
};var unsafeFromArray = _unsafeCoerce;
var toArray = _unsafeCoerce;
var unzip$1 = function () {
    var $43 = bimap(bifunctorTuple)(unsafeFromArray)(unsafeFromArray);
    return function ($44) {
        return $43(unzip(toArray($44)));
    };
}();
var concatMap$1 = flip(bind(bindNonEmptyArray));
var concat = function () {
    var $60 = map(functorNonEmptyArray)(toArray);
    return function ($61) {
        return unsafeFromArray(_concat(toArray($60($61))));
    };
}();
var adaptMaybe = function (f) {
    var $64 = fromJust();
    return function ($65) {
        return $64(f(toArray($65)));
    };
};
var head$1 = adaptMaybe(head);
var adaptAny = function (f) {
    return function ($67) {
        return f(toArray($67));
    };
};
var length = adaptAny(_length);var _toCharArray = function (s) {
  return s.split("");
};var solve = function () {
    var count = function (s) {
        var v = function (v1) {
            {
                return 0;
            }        };
        var $4 = function () {
            var $6 = find(foldableArray)(function (na) {
                return head$1(na) === "R";
            });
            var $7 = group(eqChar);
            return function ($8) {
                return $6($7($8));
            };
        }()(_toCharArray(s));
        if ($4 instanceof Just) {
            return length($4.value0);
        }        return v();
    };
    var $9 = show(showInt);
    return function ($10) {
        return $9(count($10));
    };
}();var _readAll = function () {
  return function () {
    return fs.readFileSync("/dev/stdin", "utf8");
  };
};var _log = function (s) {
  return function () {
    console.log(s);
    return {};
  };
};var interact = function (solve) {
    return bind(bindEffect)(mapFlipped(functorEffect)(_readAll())(solve))(_log);
};var main = interact(solve);
var _default = {
    main: main
};exports.__reserved_default=_default;exports.main=main;
main();