It's my first problem which I have solved online!