#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353ll;
long long n, m, a[505], mn[505][505];
long long f[505][505];
long long dp(long long l, long long r) {
  if (l >= r) return 1;
  if (f[l][r] >= 0) return f[l][r];
  long long sl = 0, sr = 0;
  for (long long i = l; i <= mn[l][r]; i++)
    sl = (sl + dp(l, i - 1) * dp(i, mn[l][r] - 1) % M) % M;
  for (long long i = r; i >= mn[l][r]; i--)
    sr = (sr + dp(i + 1, r) * dp(mn[l][r] + 1, i) % M) % M;
  return f[l][r] = sl * sr % M;
}
signed main() {
  memset(f, -1, sizeof(f));
  cin >> n >> m;
  for (long long i = 1; i <= n; cin >> a[i++])
    ;
  for (long long i = 1; i <= n; i++)
    for (long long j = i; j <= n; j++) {
      mn[i][j] = i;
      for (long long k = i + 1; k <= j; k++)
        if (a[k] < a[mn[i][j]]) mn[i][j] = k;
    }
  cout << dp(1, n) << endl;
}
