## Another Contest 5 Problem 2 - Great Graffiti

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type

Tudor is walking around the streets of Hong Kong when he sees some graffiti. He wishes to augment the graffiti so that the string DMOJ appears somewhere in the graffiti.

The graffiti is a string of letters. With a single can of paint, Tudor can insert one letter anywhere in the string.

Compute the minimum number of cans of paint Tudor needs to buy so that he can make DMOJ appear as a substring somewhere in the graffiti.

#### Constraints

will only contain letters from the string DMOJ.

#### Input Specification

The first and only line of input contains a single string, .

#### Output Specification

Output the minimum number of cans of paint Tudor must buy.

#### Sample Input

MOJ

#### Sample Output

1

• commented on Aug. 23, 2021, 11:40 p.m. edit 4

3 points is deceiving.

Nevermind, I'm just dumb. Snoogy from the best submissions has enlightened me with his massive brain.

• commented on May 10, 2020, 11:42 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Oct. 31, 2020, 10:08 p.m.

no