You need count how many valleys you will pass.

Start is always from zero level.

Every time you go down below 0 level counts as an entry of a valley, and as you go up to 0 level from valley counts as an exit of a valley.

One passed valley is equal one entry and one exit of a valley.
```
s='FUFFDDFDUDFUFUF'
U=UP
F=FORWARD
D=DOWN
```

To represent string above
```
(level 1)  __
(level 0)_/  \         _(exit we are again on level 0)
(entry-1)     \_     _/
(level-2)       \/\_/
```
So here we passed one valley

Difficulty: EASY
Starter code: def counting_valleys(s):
	

Solutions:
def counting_valleys(s):
	level = 0
	in_valley = False
	count = 0
	for c in s:
		if c == 'U':
			level += 1
		elif c == 'D':
			level -= 1
		if level >= 0 and in_valley:
			count += 1
		in_valley = level < 0
	return count


def counting_valleys(s):
	last_level = level = 0
	c = 0
	for m in s:
		if m == 'F':
			continue
		level += (-1, 1)[m == 'U']
		if last_level < level == 0:
			c += 1
		last_level = level
	return c


def counting_valleys(s):
	(level, valleys) = (0, 0)
	for step in s:
		if step == 'U' and level == -1:
			valleys += 1
		level += {'U': 1, 'F': 0, 'D': -1}[step]
	return valleys


def counting_valleys(s):
	s = list(s)
	s = list(filter(lambda x: x != 'F', s))
	for i in range(len(s)):
		if s[i] == 'D':
			s[i] = -1
		if s[i] == 'U':
			s[i] = 1
	count = 0
	sum = 0
	for i in range(len(s)):
		sum += s[i]
		if sum == 0 and s[i] == 1:
			count += 1
	return count


def counting_valleys(s):
	altitude = 0
	result = 0
	for c in s:
		if c == 'U':
			altitude += 1
			if altitude == 0:
				result += 1
		elif c == 'D':
			altitude -= 1
	return result


def counting_valleys(s):
	r = l = 0
	for x in s:
		if x == 'U' and l == -1:
			r += 1
		if x != 'F':
			l += 1 if x == 'U' else -1
	return r


def counting_valleys(s):
	res = current = 0
	for c in s:
		if c == 'U':
			current += 1
			if current == 0:
				res += 1
		elif c == 'D':
			current -= 1
	return res


def counting_valleys(walk):
	(level, valleys) = (0, 0)
	for step in walk:
		valleys += level == -1 and step == 'U'
		level += step == 'U' or -(step == 'D')
	return valleys


def counting_valleys(s):
	(res, cnt) = (0, 0)
	for i in s:
		cnt += {'F': 0, 'U': 1, 'D': -1}[i]
		if cnt == 0 and i == 'U':
			res += 1
	return res


def counting_valleys(s):
	c = 0
	t = 0
	test = []
	for a in range(len(s)):
		if s[a] == 'F':
			test.append(t)
		elif s[a] == 'U':
			test.append(t + 1)
			t += 1
		else:
			test.append(t - 1)
			t -= 1
	for a in range(len(test) - 1):
		if test[a] == -1 and test[a + 1] == 0:
			c += 1
	return c
	pass