codeparrot/codecomplex huggingface dataset:
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    final int N = 5010;
    final int M = 1_000_000_007;
    long[][] dp = new long[2][N];
    long[] sums = new long[N];
    char[] p = new char[N];
    Scanner sca = new Scanner(System.in);
    void start() {
        int n = Integer.parseInt(sca.nextLine());
        int idx = 0;
        Arrays.fill(dp[idx], 0);
        dp[idx][0] = 1;
        for (int i = 0; i < n; i++) p[i] = sca.nextLine().charAt(0);
        for (int i = 0; i < n;) {
            int nidx = idx ^ 1;
            Arrays.fill(dp[nidx], 0);
            Arrays.fill(sums, 0);
            int j = i;
            while (p[j] != 's') j++;
            int levels = j - i;
            i = j+1;
            for (j = n; j >= 0; j--) {
                sums[j] = sums[j + 1] + dp[idx][j];
                if (sums[j] >= M) sums[j] -= M;
            }
            for (j = 0; j <= n; j++) {
                int ind = j + levels;
                if (ind > n) continue;
                dp[nidx][ind] = sums[j];
            }
            idx = nidx;
        }
        long ans = 0;
        for (int i = 0; i <= n; i++) {
            ans += dp[idx][i];
            if (ans >= M) ans -=M;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {

        new Test().start();

    }
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.io.*;
import java.util.*;
public class CC {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		s=new char [n];
		for(int i=0;i<n;i++)
			s[i]=sc.next().charAt(0);
		mem=new int [2*n+1][n+1];
		for(int [] x : mem)
			Arrays.fill(x, -1);
		pw.println(dp(0, 0));
		
		pw.flush();
		pw.close();
	}
	static int n;
	static char [] s;
	static int [][] mem;
	
	static int dp(int i,int j){
		if(i==n)
			return j==0? 1 : 0;
		if(mem[i][j]!=-1)
			return mem[i][j];
		int ans=0;
		if(s[i]=='f'){
			ans+=dp(i+1, j+1);
			ans%=mod;
		}else{
			ans+=dp(i+1, j);
			ans%=mod;
			if(j>0){
				ans+=dp(i, j-1);
				ans%=mod;
			}
		}
		
		return mem[i][j]=ans;
	}
	
	static int mod=(int)(1e9+7);

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.*;
import java.io.*;

public class PythonIndentation {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(in.readLine());
		int[][] dp = new int[N][N];
		dp[0][0] = 1;
		for(int i = 1; i < N; ++i) {
			char lastCmd = in.readLine().charAt(0);
			int[] sum = new int[N];
			sum[N - 1] = dp[i - 1][N - 1];
			for(int j = N - 2; j >= 0; --j)
				sum[j] = (sum[j + 1] + dp[i - 1][j]) % 1000000007;
			for(int j = 0; j < N; ++j) {
				if(lastCmd == 'f' && j > 0)
					dp[i][j] = dp[i - 1][j - 1];
				else if(lastCmd == 's')
					dp[i][j] = sum[j];
			}
		}
		int ans = 0;
		for(int i = 0; i < N; ++i)
			ans = (ans + dp[N - 1][i]) % 1000000007;
		System.out.println(ans);
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.* ;
import java.io.* ;

public class PythonIndentation
{
	public static void main(String args[])
	{
		Scanner in = new Scanner(System.in) ;
		int n = in.nextInt() ;
		boolean[] lst = new boolean[n] ;
		for(int i=0;i<n;i++)
		{
			lst[i] = (in.next().equals("s"))?false:true ;
		}
		System.out.println(dp(lst)) ;
	}
	static long dp(boolean[] lst)
	{//false in lst means an "s" (simple statement), and true a "f"(for loop)
		long[][] dp = new long[lst.length][lst.length] ;
		dp[0][0] = 1 ;
		for(int i=1;i<lst.length;i++)
		{
			
			for(int j=0;j<lst.length;j++)
			{
				if(lst[i-1])//(i-1)st statement is a for loop 
				{
					if(j==0)
						dp[i][j] = 0 ;
					else
						dp[i][j] = dp[i-1][j-1] ;
				}
			
				else//i-1 st statement is a simple statement
				{
					if(j==0)
					{
						for(int k=0;k<lst.length;k++)
							dp[i][j] = (dp[i][j]+dp[i-1][k])%1000000007 ;
					}
					else
						dp[i][j] = (dp[i][j-1]-dp[i-1][j-1])%1000000007 ;
				}
			}
		}
		long ans = 0 ;
		for(int i=0;i<lst.length;i++)
		{
			ans = (ans + dp[lst.length-1][i])%1000000007 ;
		}
		if(ans<0)
			ans = ans + 1000000007 ;
		return ans ;
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.*;
import java.io.*;

public class c implements Runnable{
	int N;
	int[] arr;
	public static void main(String[] args) { new Thread(null, new c(), "", 1<<27).start(); } public void run() {
		arr = new int[N = nextInt()];
		for(int n=0;n<N;n++) {
//			System.out.println(n+" s");
			if(nextString().charAt(0) == 'f') {
				arr[n] = 1;
			}
		}
		long[][] dp = new long[N+1][N+1];
		dp[0][0] = 1;
		for(int i = 0; i < N; i++) {
			// if this is an s
			if(arr[i] == 0) {
				// transition from the one directly above and everything to the right of that
				// for each dp space. using cumulative sums will make this easier
				long sum = 0;
				for(int j = N; j >= 0; j--) {
					sum += dp[i][j];
					sum %= 1_000_000_007L;
					dp[i+1][j] += sum;
					dp[i+1][j] %= 1_000_000_007L;
				}
			}
			// otherwise, this is an f
			else {
				// transition from the spot on the top left
				for(int j = 1; j <= N; j++) {
					dp[i+1][j] += dp[i][j-1];
					dp[i+1][j] %= 1_000_000_007L;
				}
			}
		}
		
		// answer is the sum of the last row
		long ans = 0;
		for(long l : dp[N-1]) ans = (ans + l) % 1_000_000_007;
		System.out.println(ans);
	}
	

	// fast scanner stuff
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] line = null; int line_ptr = 0;
	void read() {
		try {
			line = br.readLine().split(" ");
		}
		catch(IOException ioe) {
			System.err.println("bad input");
			line = null;
		}
	}
	void ensure() {
		while(line == null || line.length <= line_ptr) {
			read();
			line_ptr = 0;
		}
	}
	int nextInt() {
		ensure();
		return Integer.parseInt(line[line_ptr++]);
	}
	long nextLong() {
		ensure();
		return Integer.parseInt(line[line_ptr++]);
	}
	String nextString() {
		ensure();
		return line[line_ptr++];
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class C {

    static int MOD = 1_000_000_007;

    public static void main(String[] args) {

        MyScanner in = new MyScanner();
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        char prev = ' ';

        // index, maxNumOfIntents -> count
        int[][] dp = new int[n+1][n+2];

        dp[0][0] = 1;
        for(int i=0;i<n;++i){
            char ch = in.next().charAt(0);
            if(prev == 's'){
                int sum = 0;
                for(int j=n;j>=0;--j){
                    sum = (sum + dp[i-1][j]) % MOD;
                    dp[i][j] = sum;
                }
            }else if(prev == 'f'){
                for(int j=0;j<n;++j){
                    dp[i][j+1] = dp[i-1][j];
                }
            }

            prev = ch;
        }

        int result = 0;
        for(int i=0;i<=n;++i){
            result = (result + dp[n-1][i]) % MOD;
        }


        out.println(result);
        out.close();

    }


    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    // --------------------------------------------------------

}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.*;
public class PythonIndentation {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		int a[]=new int[t];
		int c=0;
		a[0]=1;
		long mod=(long) (1e9+7);
		sc.nextLine();
		for(int i=0;i<t;i++)
		{
			String s=sc.nextLine();
			if(s.equals("f"))
				c++;
			else
			{
				for(int j=1;j<=c;j++)
				{
					a[j]=(int) (((a[j]%mod)+(a[j-1]%mod))%mod);
				}
			}
		}
		
		System.out.println(a[c]);
		sc.close();
		
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.Scanner;

public class Main3 implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main3(), "", 128 * 1024 * 1024).start();
    }

    private static Scanner in = new Scanner(System.in);

    public void run() {
        int n = in.nextInt();
        int m = 1_000_000_007;
        boolean[] state = new boolean[n];
        for (int i = 0; i < n; i++) {
            state[i] = in.next().equals("f");
        }
        // 使うのは[n][n]だけど、j+1==nのときif分岐せずに済むようにn+1にしてる
        long[][] dp = new long[n][n + 1];
        dp[0][0] = 1;
        // iは既に埋まっていてi+1に書き込んでいくから、i<n-1まででいい
        for (int i = 0; i < n - 1; i++) {
            if (state[i]) {
                // 右下にコピーしていくから溢れないようにj<n-1
                for (int j = 0; j < n - 1; j++) {
                    dp[i + 1][j + 1] = dp[i][j];
                }
            } else {
                // 何通りかというのを右から埋めていくからj--で進める
                for (int j = n - 1; j >= 0; j--) {
                    // 足していくと大きくなるからこの時点でもう%mしておく
                    dp[i + 1][j] = (dp[i][j] + dp[i + 1][j + 1]) % m;
                }
            }
        }
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += dp[n - 1][i] % m;
        }
        System.out.println(sum % m);
    }
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.io.* ;
import java.util.* ;
import java.text.* ;
import java.math.* ;
import static java.lang.Math.min ;
import static java.lang.Math.max ;
public class Codeshefcode{
	public static void main(String[] args) throws IOException{
		Solver Machine = new Solver() ;
		Machine.Solve() ;
		Machine.Finish() ;
		// new Thread(null,new Runnable(){
		// 	public void run(){
		// 		Solver Machine = new Solver() ;
		// 		try{
		// 			Machine.Solve() ;
		// 			Machine.Finish() ;
		// 		}catch(Exception e){
		// 			e.printStackTrace() ;
		// 			System.out.flush() ;
		// 			System.exit(-1) ;
		// 		}catch(Error e){
		// 			e.printStackTrace() ;
		// 			System.out.flush() ;
		// 			System.exit(-1) ;
		// 		}
		// 	}
		// },"Solver",1l<<27).start() ;
	}
}
class Mod{
	static long mod=1000000007 ;
	static long d(long a,long b){ return (a*MI(b))%mod ; }
	static long m(long a,long b){ return (a*b)%mod ; }
	static private long MI(long a){ return pow(a,mod-2) ; }
	static long pow(long a,long b){
		if(b<0) return pow(MI(a),-b) ;
		long val=a ; long ans=1 ;
		while(b!=0){
			if((b&1)==1) ans = (ans*val)%mod ; 
			val = (val*val)%mod ; 
			b/=2 ;
		}
		return ans ;
	}	
}
class pair implements Comparable<pair>{
	int x ; int y ;  
	pair(int x,int y){ this.x=x ; this.y=y ;} 
	public int compareTo(pair p){
		return (this.x<p.x ? -1 : (this.x>p.x ? 1 : (this.y<p.y ? -1 : (this.y>p.y ? 1 : 0)))) ;
	}
}
class Solver{
	Reader ip = new Reader(System.in) ;	  
	PrintWriter op = new PrintWriter(System.out) ;
	long dp[][] ;
	public void Solve() throws IOException{
		int n = ip.i() ;
		int arr[] = new int[n] ;
		dp = new long[n][n] ;
		for(int i=0 ; i<n ; i++)
			for(int j=0 ; j<n ; j++)
				dp[i][j]=-1 ;
		for(int i=0 ; i<n ; i++){
			String s = ip.s() ;
			if(s.compareTo("s")==0) arr[i]=0 ;
			else if(s.compareTo("f")==0) arr[i]=1 ;
			else throw new IOException() ;
		}
		for(int j=0 ; j<n ; j++) dp[n-1][j] = 1 ;
		for(int i=(n-2) ; i>=0 ; i--){
			long cuml[] = new long[n] ;
			for(int j=0 ; j<n ; j++) cuml[j] = (dp[i+1][j]+(j==0 ? 0 : cuml[j-1]))%Mod.mod ;
			for(int j=0 ; j<n ; j++)
				dp[i][j] = (arr[i]==0 ? cuml[j] : (j==(n-1) ? -1 : dp[i+1][j+1])) ;
		}
		pln(dp[0][0]) ;
	}
	void Finish(){
		op.flush();
		op.close();
	}
	void p(Object o){
		op.print(o) ;
	}
	void pln(Object o){
		op.println(o) ;
	}		
}
class mylist extends ArrayList<String>{}
class myset extends TreeSet<Integer>{}
class mystack extends Stack<Integer>{}
class mymap extends TreeMap<Long,Integer>{}
class Reader {
	BufferedReader reader;
	StringTokenizer tokenizer;
	Reader(InputStream input) {
		reader = new BufferedReader(
					new InputStreamReader(input) );
		tokenizer = new StringTokenizer("") ;
	}
	String s() throws IOException {
		while (!tokenizer.hasMoreTokens()){
			tokenizer = new StringTokenizer(
			reader.readLine()) ;
		}
		return tokenizer.nextToken();
	}
	int i() throws IOException {
		return Integer.parseInt(s()) ;
	}
	long l() throws IOException{
		return Long.parseLong(s()) ;
	}
	double d() throws IOException {
		return Double.parseDouble(s()) ;
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.io.*;
import java.util.*;

public final class PythonIndentation
{
	public static void main(String[] args)
	{
		new PythonIndentation(System.in, System.out);
	}

	static class Solver implements Runnable
	{
		static final int MOD = (int) 1e9 + 7;
		int n;
		char[] arr;
		long[][] dp;
		BufferedReader in;
		PrintWriter out;

		void solve() throws IOException
		{
			n = Integer.parseInt(in.readLine());
			arr = new char[n];
			dp = new long[n + 1][n + 1];

			for (int i = 0; i < n; i++)
				arr[i] = in.readLine().charAt(0);

			for (int i = 0; i <= n; i++)
				Arrays.fill(dp[i], -1);

			dp[0][0] = 1;

			if (arr[0] == 's')
				out.println(find(1, 0));
			else
				out.println(find(1, 1));
		}

		long find(int curr, int backIndents)
		{
			if (backIndents < 0)
				return 0;

			if (curr == n)
				return 1;

			if (dp[curr][backIndents] != -1)
				return dp[curr][backIndents];

			long ans;

			if (arr[curr] == 's')
			{
				if (arr[curr - 1] == 'f')
					ans = find(curr + 1, backIndents);
				else
					ans = CMath.mod(find(curr + 1, backIndents) + find(curr, backIndents - 1), MOD);
			}
			else
			{
				ans = find(curr + 1, backIndents + 1);

				if (arr[curr - 1] != 'f')
					ans = CMath.mod(ans + find(curr, backIndents - 1), MOD);
			}

			return dp[curr][backIndents] = ans;
		}

		public Solver(BufferedReader in, PrintWriter out)
		{
			this.in = in;
			this.out = out;
		}

		@Override public void run()
		{
			try
			{
				solve();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	static class CMath
	{
		static long mod(long number, long mod)
		{
			return number - (number / mod) * mod;
		}

	}

	private PythonIndentation(InputStream inputStream, OutputStream outputStream)
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
		PrintWriter out = new PrintWriter(outputStream);
		Thread thread = new Thread(null, new Solver(in, out), "PythonIndentation", 1 << 29);

		try
		{
			thread.start();
			thread.join();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		finally
		{
			try
			{
				in.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}

			out.flush();
			out.close();
		}
	}

}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class C {
	static char[] arr;
	static int mod = (int) 1e9 + 7;
	static int[][] memo;
	static int n;

	static int solve(int idx, int depth) {
		if (idx == n) {
			return depth == 0 ? 1 : 0;
		}
		if (memo[idx][depth] != -1)
			return memo[idx][depth];
		int ret = 0;
		if (arr[idx] == 's') {
			if (depth > 0)
				ret = ret + solve(idx, depth - 1);
			ret = (ret + solve(idx + 1, depth)) % mod;
		}
		if (arr[idx] == 'f' || arr[idx] == 'z')
			ret = (ret + solve(idx + 1, depth + 1)) % mod;
		return memo[idx][depth] = ret;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		arr = new char[n];
		for (int i = 0; i < n; i++)
			arr[i] = sc.next().charAt(0);
		memo = new int[n + 1][n + 1];
		for (int[] x : memo)
			Arrays.fill(x, -1);
		System.out.println(solve(0, 0));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.Scanner;
public class maestro{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long mod = (long)Math.pow(10,9)+7;
        long[][] arr = new long[N][N];
        arr[0][0]=1;
        for (int i=1;i<N;i++){
            char c = sc.next().charAt(0);
            if (c=='f'){
                for (int j=1;j<N;j++) arr[i][j] = arr[i - 1][j - 1];
            }
            else {
                long sum=0;
                for (int j=N-1;j>=0;j--){
                    sum=(sum+arr[i-1][j])%mod;
                    arr[i][j] = sum;
                }
            }
        }
        long ans=0;
        for (int i=0;i<N;i++) ans=(ans+arr[N-1][i])%mod;
        System.out.println(ans);
    }
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.util.* ;


public class PythonIndentation
{
	public static void main(String args[])
	{
		Scanner in = new Scanner(System.in) ;
		int n = in.nextInt() ;
		boolean[] lst = new boolean[n] ;
		for(int i=0;i<n;i++)
		{
			lst[i] = (in.next().equals("s"))?false:true ;
		}
		System.out.println(dp(lst)) ;
	}
	
	static int dp(boolean[] lst)
	{//false in lst means an "s" (simple statement), and true a "f"(for loop)
		int[][] dp = new int[2][lst.length] ;
		dp[0][0] = 1 ;
		for(int i=1;i<lst.length;i++)
		{
			
			for(int j=0;j<lst.length;j++)
			{
				if(lst[i-1])//(i-1)st statement is a for loop 
				{
					if(j==0)
						dp[i%2][j] = 0 ;
					else
						dp[i%2][j] = dp[(i-1)%2][j-1] ;
				}
			
				else//i-1 st statement is a simple statement
				{
					if(j==0)
					{
						int temp = 0 ;
						for(int k=0;k<lst.length;k++)
							temp = (temp+dp[(i-1)%2][k])%1000000007 ;
						dp[i%2][j] = temp ;
					}
					else
						dp[i%2][j] = (dp[i%2][j-1]-dp[(i-1)%2][j-1])%1000000007 ;
				}
			}
		}
		int ans = 0 ;
		for(int i=0;i<lst.length;i++)
		{
			ans = (ans + dp[(lst.length-1)%2][i])%1000000007 ;
		}
		if(ans<0)
			ans = ans + 1000000007 ;
		
		return ans ;
	}
}
// Problem: 909_C. Python Indentation
// Time complexity: quadratic
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class C {
	
	//why am I MLE'ing???
	
	int n;
	char[] a;
	long[][] memo;
	long mod = (long) 1e9 + 7;
	
	boolean lastFor(int i) {
		if(i == 0) return false;
		return a[i - 1] == 'f';
	}
	
	long dp(int ind, int curIndent) {
		if(ind == n) return 1;
		if(curIndent < 0) return 0;
		if(memo[ind][curIndent] != -1) return memo[ind][curIndent];
		long ans = 0;
		if(a[ind] == 'f' && lastFor(ind)) {
			ans += dp(ind + 1, curIndent + 1);
		} else if(a[ind] == 'f' && !lastFor(ind)) {
			ans += dp(ind, curIndent - 1);
			ans += dp(ind + 1, curIndent + 1);
//			for(int indent = 1; indent <= curIndent + 1; ++indent) {
//				ans += dp(ind + 1, indent);
//			}
		} else if(a[ind] == 's' && lastFor(ind)) {
			ans += dp(ind + 1, curIndent);
		} else if(a[ind] == 's' && !lastFor(ind)) {
			ans += dp(ind + 1, curIndent);
			ans += dp(ind, curIndent - 1);
//			for(int indent = 0; indent <= curIndent; ++indent) {
//				ans += dp(ind + 1, indent);
//			}
		}
		return memo[ind][curIndent] = ans % mod;
	}
	
	public void solve(Scanner in, PrintWriter out) {
		n = in.nextInt();
		a = new char[n];
		int forCount = 0;
		int[] fc = new int[n + 1];
		for(int i = 0; i < n; ++i) {
			a[i] = in.next().charAt(0);
			if(a[i] == 'f') ++forCount;
			fc[i] = forCount;
		}
		fc[n] = fc[n - 1];
//		long time = System.currentTimeMillis();
		memo = new long[n][forCount + 1];
		for(long[] aa : memo) {
			Arrays.fill(aa, -1);
		}
		for(int i = n; i >= 0; --i) {
			for(int indent = fc[i] - 1; indent >= 0; --indent) {
				dp(i, indent);
			}
		}
		out.println(dp(0, 0) % mod);
//		System.out.println(System.currentTimeMillis() - time);
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		new C().solve(in, out);

		in.close();
		out.close();
	}
}