#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5, mod = 998244353;
int n, m, a[N], dp[N][N];
int solve(int l, int r) {
  if (l >= r) return 1;
  if (dp[l][r] != -1) return dp[l][r];
  long long p = -1, suml = 0, sumr = 0;
  for (int i = l; i <= r; i++)
    if (p == -1 || a[i] < a[p]) p = i;
  for (int i = l; i <= p; i++)
    suml = (suml + (1LL * solve(i, p - 1) * solve(l, i - 1)) % mod) % mod;
  for (int i = r; i >= p; i--)
    sumr = (sumr + (1LL * solve(p + 1, i) * solve(i + 1, r)) % mod) % mod;
  return dp[l][r] = (suml * sumr) % mod;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << solve(1, n) << '\n';
  return 0;
}
