#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a;
    int dp[n];
    int ans=0;
    for(int i=0;i<n;i++)dp[i]=1e9;
    for(int i=0;i<n;i++){
        cin >> a;
        a *= (-1);
        *upper_bound(dp,dp+n,a)=a;
    }
    cout << lower_bound(dp,dp+n,1e9)-dp;
}
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
using ll = long long;

int main(){ 
  int  h1, m1, h2, m2 ,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h3 = h2 -1;
  int m3 = m2 + 60;
  int a = (h3-h1)*60+(m3-m1);
  cout << max(a-k, 0) << endl;
  return 0;
} 