text: 
  /* Given two sequences, find the length of longest subsequence present in both of them.
  A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous.
  For example, “abc”, “abg”, “bdf”, “aeg”, ‘”acefg”,etc are subsequences of “abcdefg”. */
  /*
  Sample Input:
  6 6
  ABCDGH
  AEDFHR
  
  Output: 3
  
  
  Explanation: LCS for input Sequences
  “ABCDGH” and “AEDFHR” is “ADH” of
  length 3.
  */
  
  #include<bits/stdc++.h>
  const int mod=1e9+7;
  using namespace std;
  
   // } Driver Code Ends
  // function to find longest common subsequence
  
  class Solution
  {
      public:
      //Function to find the length of longest common subsequence in two strings.
      int lcs(int n, int m, string s1, string s2)
      {
          vector<vector<int>>dp(n+1,vector<int>(m+1,0));
          
          for(int i=1;i<n+1;i++){
              for(int j=1;j<m+1;j++){
                  if(s1[i-1]==s2[j-1])
                  dp[i][j]=1+dp[i-1][j-1];
                  else
                  dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
              }
          }
          return dp[n][m];
      }
  };
  
  
  // { Driver Code Starts.
  int main()
  {
      int n,k,x,y;
     
      
          cin>>x>>y;          // Take size of both the strings as input
          string s1,s2;
          cin>>s1>>s2;        // Take both the string as input
          Solution ob;
          cout << ob.lcs(x, y, s1, s2) << endl;
      
      return 0;
  }
    // } Driver Code Ends}
  