#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505;
int a[MAXN];
bool been[MAXN][MAXN];
int memo[MAXN][MAXN];
const int MOD = 998244353;
inline int add(int a, int b) { return (a + b) % MOD; }
inline int mul(int a, int b) { return (long long)a * b % MOD; }
int solve(int l, int r) {
  if (been[l][r]) return memo[l][r];
  if (l >= r) return 1;
  been[l][r] = true;
  int mn = a[l], mnidx = l;
  for (int i = l + 1; i <= r; i++) {
    if (a[i] < mn) {
      mn = a[i];
      mnidx = i;
    }
  }
  int ans = 0;
  int sum_left = 0;
  for (int ll = mnidx; ll >= l; ll -= 1) {
    sum_left = add(sum_left, mul(solve(l, ll - 1), solve(ll, mnidx - 1)));
  }
  int sum_right = 0;
  for (int rr = mnidx; rr <= r; rr += 1) {
    sum_right = add(sum_right, mul(solve(mnidx + 1, rr), solve(rr + 1, r)));
  }
  ans = mul(sum_left, sum_right);
  return memo[l][r] = ans;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  printf("%d\n", solve(1, n));
  return 0;
}
