#include <bits/stdc++.h>
using namespace std;
const int N = 510;
const int mod = 998244353;
int f[N][N];
int arr[N];
int pmin[N][N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (j == i) {
        pmin[i][j] = i;
      } else {
        if (arr[pmin[i][j - 1]] > arr[j]) {
          pmin[i][j] = j;
        } else {
          pmin[i][j] = pmin[i][j - 1];
        }
      }
    }
  }
  for (int i = 0; i <= n; i++) f[i][i] = f[i + 1][i] = 1;
  for (int len = 2; len <= n; len++) {
    for (int i = 1; i + len - 1 <= n; i++) {
      int j = i + len - 1;
      int t = pmin[i][j];
      int ans1 = 0, ans2 = 0;
      for (int k = i; k <= t; k++) {
        (ans1 += 1ll * f[i][k - 1] * f[k][t - 1] % mod) %= mod;
      }
      for (int k = t; k <= j; k++) {
        (ans2 += 1ll * f[t + 1][k] * f[k + 1][j] % mod) %= mod;
      }
      f[i][j] = (1ll * ans1 * ans2) % mod;
    }
  }
  cout << f[1][n] << endl;
}
